Javascript Email Validation With Regular Expression

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

Leave a comment

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