Validate Email Address in Javascript


Below is a nice little Javascript RegularExpression to validate email addresses.

/^\w.+@[a-zA-Z_.]+?\.[a-zA-Z.]{2,3}$/

..and to use it..

if (/^\w.+@[a-zA-Z_.]+?\.[a-zA-Z.]{2,3}$/.test(email)) alert("Success");
else alert("Fail");