Regular expression for validating email address in asp net

Now you can ask questions directly to me on my new site ASPForums.

Net Question Answer site, specially started to allow visitors of this site ask their doubts and queries. Just click the Ask Now button and ask your question now.

A regular expression is a pattern describing a certain amount of text. NET Framework regular expression classes are part of the base class library and can be used with any language or tool that targets the common language runtime, including ASP.

We can validate email address at client side and server side.

An email address is a string of a subset of ASCII characters separated into two parts by an @ symbol .

The part before the @ sign is the local part of the address, and the part after the @ sign is a domain name to which the email message will be sent .

^ #start of the line [_A-Za-z0-9-\ ] # must start with string in the bracket [ ], must contains one or more ( ) ( # start of group #1 \.[_A-Za-z0-9-] # follow by a dot "." and string in the bracket [ ], must contains one or more ( ) )* # end of group #1, this group is optional (*) @ # must contains a "@" symbol [A-Za-z0-9-] # follow by string in the bracket [ ], must contains one or more ( ) ( # start of group #2 - first level TLD checking \.[A-Za-z0-9] # follow by a dot "." and string in the bracket [ ], must contains one or more ( ) )* # end of group #2, this group is optional (*) ( # start of group #3 - second level TLD checking \.[A-Za-z] # follow by a dot "." and string in the bracket [ ], with minimum length of 2 ) # end of group #3 $ #end of the line The combination means, email address must start with “_A-Za-z0-9-\ ” , optional follow by “.[_A-Za-z0-9-]”, and end with a “@” symbol. Email is valid : [email protected], true Email is valid : [email protected], true Email is valid : [email protected], true Email is valid : [email protected], true Email is valid : [email protected], true Email is valid : [email protected] , true Email is valid : [email protected], true Email is valid : [email protected] , true Email is valid : mkyong [email protected], true Email is valid : [email protected], true Email is valid : mkyong , false Email is valid : [email protected] , false Email is valid : [email protected] , false Email is valid : [email protected], false Email is valid : [email protected] , false Email is valid : [email protected], false Email is valid : mkyong()*@, false Email is valid : [email protected]%*, false Email is valid : [email protected], false Email is valid : [email protected], false Email is valid : [email protected]@, false Email is valid : [email protected] , false PASSED: Valid Email Test([

The email’s domain name must start with “A-Za-z0-9-“, follow by first level Tld (.com, .net) “.[A-Za-z0-9]” and optional follow by a second level Tld (au, my) “\.[A-Za-z]”, where second level Tld must start with a dot “.” and length must equal or more than 2 characters.

Not all browsers support Java Script, and different versions of browsers support different versions of Java Script, so client-side validation is never guaranteed to work.

Traditionally, Web developers have faced a tough choice when adding form validation logic to their pages.

You can add form validation routines to your server-side code, or you can add the validation routines to your client-side code.

Error Message="Please enter in email format." Control To Validate="txt Email" Set Focus On Error="true" Validation Expression="\w ([- .']\w )*@\w ([-.]\w )*\.\w ([-.]\w )*" Validation Group="A" Fore Color="" Css Class="Validation-Msg" Display="Dynamic"you can use client side validations or server side validations for regular expressions..better to use client side validations..check out this link it may helps you Sayyad .

For further reading on this topic: Phil Haack’s article on email address validation CSS Go / Golang ASP.

Search for regular expression for validating email address in asp net:

regular expression for validating email address in asp net-5regular expression for validating email address in asp net-78regular expression for validating email address in asp net-6regular expression for validating email address in asp net-18

[email protected] – “.a” is not a valid tld, last tld must contains at least two characters 4. mkyong()*@– email’s is only allow character, digit, underscore and dash 8.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “regular expression for validating email address in asp net”