Regular Expression for Email Validation in Asp.Net

This is the Regular Expression I use for Validating Email Address from end user responses.

<asp:RegularExpressionValidator ID="EmailExpressionValidator" runat="server"
     ControlToValidate="InputEmail"
     Display="Dynamic"
     ErrorMessage="Email format is invalid"
     Text="*"
     SetFocusOnError="true"
     ValidationExpression="^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$"
     ValidationGroup="FormValidationGroup">
</asp:RegularExpressionValidator>

Reference
I would like to acknowledge thanks to Dave for sharing this with everyone.
http://stackoverflow.com/questions/936870/best-regular-expression-for-email-format-validation-with-asp-net-3-5-validation

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s