javascript - How to validate email after the '.(dot)' while submitting form using Jquery Plugin - Stack Overflow

I'm trying to validate a form having an email address whose prop is set to 'true' as sho

I'm trying to validate a form having an email address whose prop is set to 'true' as shown:

$( "#myform" ).validate({
  rules: {
   field: {
    required: true,
     email: true
    }
  }
});

I checked out the jquery plugin / and i see that the email address gets verified only until the '@' symbol(example in the above link). I'm making a email validation script that basically just checks for plete emailaddress including the 'dot' at the end. any ideas how to achieve this??

/

I'm trying to validate a form having an email address whose prop is set to 'true' as shown:

$( "#myform" ).validate({
  rules: {
   field: {
    required: true,
     email: true
    }
  }
});

I checked out the jquery plugin http://jqueryvalidation/email-method/ and i see that the email address gets verified only until the '@' symbol(example in the above link). I'm making a email validation script that basically just checks for plete emailaddress including the 'dot' at the end. any ideas how to achieve this??

http://jsfiddle/dbnkahee/1/

Share Improve this question asked Sep 24, 2015 at 4:26 user1234user1234 3,1596 gold badges57 silver badges117 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can add jQuery.validator.addMethod with your Regex try this:-

jQuery.validator.addMethod("emailfull", function(value, element) {
 return this.optional(element) || /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i.test(value);
}, "Please enter valid email address!");

And then use it as:-

$( "#myform" ).validate({
  rules: {
  field: {
   required: true,
   emailfull: true
 }
 }
});

RegEx by aSeptik see this answer

Demo

Other RegEx

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745231250a4617688.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信