Email not fully validated with jQuery validation

Email address is not fully verified, for example. I have an email field and I test it with the jQuery validation plugin. when I find something like "abbcss", it says the letter is invalid. then I put "abbcss @g", the error disappeared, and, as you can see, the letter is still invalid. for a better understanding, I bring a violin here.

$(document).ready(function(e) { $('#email').keyup(function(){ $('#checkform').validate(); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <link href="//getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"/> <script src="//cdn.jsdelivr.net/jquery.validation/1.15.0/jquery.validate.js"></script> <form id="checkform"> <input id="email" type="email" name="email"> </form> <hr> <p>Try to put first "abcc" and click outside field </p> <p>then try to put " abcc@gmail " and click outside field </p> <p>it will consider it a valid email but actually it is not.</p> 

any help on this issue will be assigned.

+6
source share
1 answer

You can check email with jquery check plugin add method

 jQuery.validator.addMethod("validate_email", function(value, element) { if (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value)) { return true; } else { return false; } }, "Please enter a valid Email."); $('#checkform').validate({ rules: { email: { validate_email: true }, } }); 
+8
source

All Articles