Showing posts with label Java script email Validation. Show all posts
Showing posts with label Java script email Validation. Show all posts

Monday, August 31, 2009

How to Validate Emain in Java script?

function validateEmail(obj)
{
var fld=0;
var goodEmail = obj.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

fld = obj;

if (goodEmail)
{
good = true
}
else
{
alert("Please enter a valid email address.")
setTimeout("fld.focus();",1);
setTimeout("fld.select();",1);
good = false
}
return good;
}

The above function validates the email.