My email validation is not checking condition properly when i give without name only domain name in text box example @gmail.com it shows valid like valid email i need to raise alert this situation. but it works at checks domain name it works fine.
My code:
if(!(email.endsWith("@yahoo.com") || email.endsWith("@gmail.com"))){ alert("Email Should be in @yahoo.com or @gmail.com"); $("#txtEmail").val(''); document.getElementById("txtEmail").focus(); return false; } Thank you
startsWithif you are not thinking ofregexwhich is pretty good solution