Friday, November 16, 2007

Email Validation via JavaScript RegEx

I cannot take credit for the RegEx that makes this function work... I got it from the technical cheat sheet gurus at VisiBone (www.visibone.com/javascript). So without further adue:



function validateEmail(email) {
//alphanum,RFC822 chars,@-sign,alphanumbs dashes & dots,2-4 letter suffix,no more no less,case insensitive
return /^[a-z0-9][^\(\)\<\>\@\,\;\:\\\"\[\]]*\@[a-z0-9][a-z0-9\-\.]*\.[a-z]{2,4}$/i.test(email);
}

No comments: