Dynamic jQuery Validate error messages with AddMethod based on the element

前端 未结 6 1549
一向
一向 2020-11-27 19:14

Let\'s say I have a custom AddMethod to jQuery Validate like:

$.validator.addMethod(\'min-length\', function (val, element) {
    // do stuff

// the error m         


        
6条回答
  •  一生所求
    2020-11-27 19:25

    code:

        $.validator.addMethod("strongePassword", function(value) {
            return /^[A-Za-z0-9\d=!\-@._*]*$/.test(value) && /[a-z]/.test(value) && /\d/.test(value) && /[A-Z]/.test(value);
        },"The password must contain at least 1 number, at least 1 lower case letter, and at least 1 upper case letter"); 
            
    

    Uses to :

      rules: { 
            password: {
                        required: !0,
                        strongePassword: true
                     },
         }
    

提交回复
热议问题