JQuery validate plugin - can't validate classes

前端 未结 3 1612
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 07:10

I\'m trying to use the jQuery validate plugin to validate classes instead of ID\'s. Despite the many threads which seem close to answering this issue - I can\'t get any of t

3条回答
  •  借酒劲吻你
    2021-01-03 07:51

    According to the docs, this should work:

    jQuery.validator.addClassRules('classNameHere', {
      required: true
    });
    

    Then you can determine whether the fields are valid by calling:

    $('.fileName').valid();
    

    Here's a link to the docs

提交回复
热议问题