Trying to ensure an email address is in the correct format, but it is showing the alert message regardless what is typed in.
How do you check if a field is NOT in the correct format?? Currently im using the code below:
[CODE]
function validateOnSubmit()
{
var email = “”;
var theEmail = document.example.email.value;
var atLoc = theEmail.indexOf(“@”,1);
var dotLoc = theEmail.indexOf(“.”,atLoc+2);
var len = theEmail.length;
if (document.example.email.value==””)
{
alert(“Please enter your email address”)
document.example.email.focus();
document.example.email.select();
return false;
}
if (document.example.email != (atLoc > 1 && dotLoc > 1 && len > dotLoc+2))
{
alert(“Please check your email address”)
return false;
}
return true;
}