View Full Version : How to do email vaildation in javascript?

05-22-2009, 11:01 AM
How do you create in javascript to do email vaildation? to check

must contain 1 @
must contain 1 letter before the @
must contain 1 letter after the @
must not contain spaces, slash, colon, comma or semicolon

if the any of the rules are wrong it will alert the user saying "Invalid Email"

Philip M
05-22-2009, 11:39 AM
Your conditions are not sufficient to validate an email address.

A proper and complete email validation is:-

if (!(/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i.test(emailAddress.value))) {
alert ("Invalid email address");
return false;

Tourist in Athens to tour guide: "You have told us something about Byzantine architecture. Would it be possible to meet some Byzants?"