js中的jQuery Validate增加手机号码验证

 

 

 

 

$.validator.addMethod("isPhone", function(value,element) {
    var length = value.length;
    var mobile = /^1[3456789]\d{9}$/;
    return this.optional(element) || (length == 11 && mobile.test(value));
}, "请正确填写您的联系电话");

 

菜鸟教程:https://www.runoob.com/jquery/jquery-plugin-validate.html

 

调用:  isPhone:true

 

posted @ 2020-05-11 18:03  yvioo  阅读(1490)  评论(0编辑  收藏  举报