jquery.validate 如何自定义验证规则


            $.validator.addMethod("isPassword", function(value, element) {
        var reg =  /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,20}$/;
        return reg.test(value);
    }, "密码中必须包含含数字、字母、特殊符号");

 

 
 
  $('#formTeacherReg').validate({
                rules: {
                    UserPwd: {
                        required: true,
                        minlength: 5,
                        isPassword:true
                    },
                    teacherRePwd: {
                        required: true,
                        minlength: 5,
                        equalTo: "#teacherPwd",
                        isPassword:true
                    },
                },

 

 
添加引用即可
 
 
 

posted on 2023-12-13 14:39  漫思  阅读(172)  评论(0编辑  收藏  举报

导航