CoDebate

Debating Code - [ASP.NET, C#, Sql Server, VB.NET]

Wednesday, July 1, 2009

ASP.NET EMail Validation – Revised.

Sometimes back, I had searched to find an easy way to validate email address with some restricted patterns such as fixed domains, common suffices, etc.

The very common regular expression for email validation is as we know:

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

But if we want to restrict emails of specific domains, that is also simply possible by :

\w+([-+.']\w+)*@(domA\.com|domB\.com)

The above expression will validate only if the emails are with @domA.com and @domB.com in the suffix.

And When we want to have a specific pattern in the email:


\w+([-+.']\w+)*@(domA+[A-Za-z0-9]*.com)

With the above expression, we can validate email ids with the format abc@domAbbb.com, acde@domAcgfdg32.com, etc. As we could have @domA as the part of the email address after @ symbol.

Labels: , , , , , , ,

posted by Karthikeyan @ 9:28 AM

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home