Okay, so I'm working on this contact form here, and everything seems to be working well. It checks if the email address has an "@" sign with the following code: (It's a function, just not shown here for ease).
JS:
var at = "@";
if (email.indexOf(at) == -1 || email.indexOf(at) == 0) {
success = false;
document.getElementById("email-error").innerHTML = "That's not an email!";
document.getElementById("email-good").innerHTML = "";
}
HTML:
<input onfocus="return validation()" type="text" name="email" id="email"><span id="email-error"></span><span id="email-good"></span>
I want to check if there is a "." (dot) in the email value with the following code, but it doesn't work!
var at = "@";
var dot = ".";
if (email.indexOf(at) == -1 || email.indexOf(at) == 0 || email.indexOf(dot) == -1 || email.indexOf(dot) == 0) {
success = false;
document.getElementById("email-error").innerHTML = "That's not an email!";
document.getElementById("email-good").innerHTML = "";
}
Also, if possible, is there a way to check if there are more than one "@" or "." ? I tried > and != 1 already.