Friday, February 8, 2008

isValidEmail(sEmail)

How many times have you wished that some build-in checks existed in the Regular Expression object? One on the ones which I use often is a check if an e-mail address is valid - so here you are! You may use it as you like! :-)




function isValidEmail(sEmail)
{
var pattern = "^[a-zA-Z0-9._+&*# -]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$"
var regex = new RegExp(pattern, 'ig');
return regex.test(sEmail);
}

No comments: