开发者

jQuery validate + ajaxSubmit on multiple forms

开发者 https://www.devze.com 2022-12-27 08:04 出处:网络
I\'m trying to validate multiple forms in one single page with the jQuery validation plugin but it validates only the first form in the page.

I'm trying to validate multiple forms in one single page with the jQuery validation plugin but it validates only the first form in the page.

Here is my code:

$('form.reply_form').validate({
  submitHan开发者_Go百科dler: function(form) {
    $(form).ajaxSubmit(optionsReplies);
    return false;
  }
});

Is for a list of reply forms in the page (image facebook). If I try to use the third form, for example, it validates the first one and if the first one is blank it wont submit.

Thank you in advance.


I'm not sure about the particular plugin you are using, but it sounds like it only uses the first element returned.
An each() method may help:

$('form.reply_form').each(function(){
    $(this).validate({
        ...
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消