Here is the code sample using jQuery
if(email.indexOf("@") < 0 || email.indexOf(".") < 0){
$("#spanInputEmail").removeClass('hideme');
$("#inputEmail").addClass('borderColor');
return;
}
CodePudding user response:
Your current condition is only checking for the email containing at least one "." and at least one "@"
You can see here a set of rules to validate that a string is a valid email address.
In your case, I would use an existing solution, to prevent reinventing the wheel, maybe this answer on SO is a good starting point
CodePudding user response:
In your if-clause, try to call a function like in this answer: How can I validate an email address in JavaScript?
To answer the question: I don't know much of the context of your script, but you're using the or operator ||
and it looks more like you want to use &&