Validating multiple forms on the same page

前端 未结 6 505
面向向阳花
面向向阳花 2021-01-14 03:03

For example I have 3 forms in a page with the same names. How can I validate all these forms with one validate method?

6条回答
  •  渐次进展
    2021-01-14 03:35

    I've created fiddlefor you. Add ids if you really need them.

    Key is to add same class to forms and validate each form.

    $('form.validateForm').each(function(key, form) {
        $(form).validate(); 
    });
    

提交回复
热议问题