jQuery validate + ajaxSubmit多种形式 [英] jQuery validate + ajaxSubmit on multiple forms

查看:112
本文介绍了jQuery validate + ajaxSubmit多种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery验证插件在一个页面中验证多个表单,但它仅验证页面中的第一个表单.

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.

这是我的代码:

$('form.reply_form').validate({
  submitHandler: function(form) {
    $(form).ajaxSubmit(optionsReplies);
    return false;
  }
});

是页面中的回复表单列表(图像facebook).例如,如果我尝试使用第三个表格,它将验证第一个表格,如果第一个空白,它将不会提交.

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.

谢谢.

推荐答案

我不确定您所使用的特定插件,但听起来它只使用返回的第一个元素.
each()方法可能有帮助:

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({
        ...
    });
});

这篇关于jQuery validate + ajaxSubmit多种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆