Javascript Email Validation With Regular Expression

Share

First lets see the code


Now the explanation

/^([a-zA-Z0-9_\.\-])+\@+([a-zA-Z0-9\-]{2,})+\.+([a-zA-Z0-9\.]{2,6})$/

^[a-zA-Z0-9_\.\-] = Matching the beginning of the string
Any character from a-z, A-Z, 0-9 and . – _
\@ = @
[a-zA-Z0-9\-]{2,} = Any character from a-z, A-Z, 0-9 and –
Number of characters should be at least 2
There are no upper limit on number of characters
\. = .
([a-zA-Z0-9\.]{2,6})$ = Matching the end of the string
Any character from a-z, A-Z, 0-9 and .
Number of characters should be between 2 and 6
This entry was posted in Javascript, Regular Expression and tagged , . Bookmark the permalink.
 

Leave a Reply

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

*