jQuery正在验证表单提交上的所有选项卡

jQuery正在验证表单提交上的所有选项卡,jquery,validation,tabs,Jquery,Validation,Tabs,目前,jQuery验证插件只验证选定的选项卡。因此,为了使所有选项卡都得到验证,我引入了ignore属性 $("form").validate({ .... .... ignore:"ui-tabs-hide" }); 但是在给出这个之后,它甚至验证了隐藏的字段。是否有一种方法可以通过仅忽略每个选项卡上的隐藏字段来验证所有选项卡上的字段 html <div id="tabs"> <%@include file="inc/tabsList.jsp" %> <!--

目前,jQuery验证插件只验证选定的选项卡。因此,为了使所有选项卡都得到验证,我引入了ignore属性

$("form").validate({
....
 ....
ignore:"ui-tabs-hide"
});
但是在给出这个之后,它甚至验证了隐藏的字段。是否有一种方法可以通过仅忽略每个选项卡上的隐藏字段来验证所有选项卡上的字段

html

<div id="tabs">
<%@include file="inc/tabsList.jsp" %> <!--has <a> link for each div -->

<div id="fragment-1"><%@include file="inc/tradeDetails.jsp" %></div>
<div id="fragment-2"><%@include file="inc/beneficiaryDetails.jsp" %></div>
<div id="fragment-3"><%@include file="inc/referenceDetails.jsp" %></div>
<div id="fragment-4"><%@include file="inc/summary.jsp"%></div>

<div class="clear"></div>

</div>

您需要禁用其他控件

试试这个:

$("div[id^=fragment-]").bind("click", function() {
   $("div[id^=fragment-]").children("input, select, textarea").prop("disabled", true);
   $(this).children("input, select, textarea").prop("disabled", false);
});

这将保持当前选项卡的控件处于启用状态,其他选项卡的控件处于禁用状态,因此验证器将仅验证选项卡中的当前元素。

卓越…解决方案是以下组合:

$("form").validate({
....
 ....
ignore:"ui-tabs-hide"
});
更多

$("div[id^=fragment-]").bind("click", function() {
   $("div[id^=fragment-]").children("input, select, textarea").prop("disabled", true);
   $(this).children("input, select, textarea").prop("disabled", false);
});

只要所有输入元素都在一个表单中,验证插件仍然应该检查它们。你可以发布一个你的HTML样本吗?谢谢你的回复,我想换一种方式。验证程序用于验证所有选项卡中可用的元素,只保留隐藏的元素。它在
jquery.validate.js
中尚不可用。您可以尝试考虑向开发人员提出功能请求。您可以帮助我在哪里发起功能请求吗?您可能会在他们的(GitHub存储库)中提出问题[
$("div[id^=fragment-]").bind("click", function() {
   $("div[id^=fragment-]").children("input, select, textarea").prop("disabled", true);
   $(this).children("input, select, textarea").prop("disabled", false);
});