I'm trying to check an email field on my website but the function that I have always returns false. The regular expression seems right but the function is not working properly.
Here is the code:
function CheckEmail(email)
{
//regular expression to check the email field
var expr = /^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$/;
if (expr.test(email)) {
document.getElementById('alertEmail').innerHTML = '<img title="Valid Email" src="images/icoOk.jpg" alt="Ok"/>';
f = true;
return true;
}
else {
document.getElementById('alertEmail').innerHTML = '<img title="Invalid Email!" src="images/icoErro.gif" alt="Erro"/>';
f = false;
return false;
}
}
any ideias??
Thank y'all so much for the help