I've been having trouble with validating an email input in a form.
Now I'm able to alert the user if they didn't input an email, or if the input is incorrect. However, if the input IS correct, it still alerts that the input is incorrect.
document.getElementById("frmContact").onsubmit = function() {
if (document.getElementById("email").value=="") {
alert("Please enter your email.")
return false;
} else if (document.getElementById("email").value !== "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$"){
alert("Please enter a valid email address.");
return false;
} else {
return true;
}
};