jQuery Validation using the class instead of the name value

前端 未结 7 1290
清酒与你
清酒与你 2020-11-29 00:09

I\'d like to validate a form using the jquery validate plugin, but I\'m unable to use the \'name\' value within the html - as this is a field also used by the server app. Sp

7条回答
  •  隐瞒了意图╮
    2020-11-29 00:56

    You can add the rules based on that selector using .rules("add", options), just remove any rules you want class based out of your validate options, and after calling $(".formToValidate").validate({... });, do this:

    $(".checkBox").rules("add", { 
      required:true,  
      minlength:3
    });
    

提交回复
热议问题