在字段集之间验证 [英] Validate between fieldsets
本文介绍了在字段集之间验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有低音强度验证的formtowizard jQuery插件.我已将我的下一个按钮附加到一个单击事件上,该事件可验证我的表单,但是我只希望它校验当前的字段集而不是整个表单...
I'm using the formtowizard jquery plugin with bassistance validation. I have attached my next button to a click event which validates my form however I only want it to validate the current fieldset not the whole form...
我的表单是这样设置的
<form id="SignupForm" method="POST" action="..................">
<fieldset>
<legend>Application</legend>
<div>
</div>
</fieldset>
<fieldset>
<legend>Step Two</legend>
<div>
</div>
</fieldset>
这是我目前正在使用的
$("a.next").click(function() {
$("#SignupForm").validate();
});
这是我的按钮被调用的地方
This is where my button gets called
function createNextButton(i) {
var stepName = "step" + i;
$("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>");
$("#" + stepName + "Next").bind("click", function(e) {
/* VALIDATION */
if (options.validationEnabled) {
var stepIsValid = true;
$("#"+stepName+" :input").each(function(index) {
checkMe = element.validate().element($(this));
//stepIsValid = !element.validate().element($(this)) && stepIsValid;
stepIsValid = checkMe && stepIsValid;
});
//alert("stepIsValid === "+stepIsValid);
if (!stepIsValid) {
return false;
};
};
$("#" + stepName).hide();
$("#step" + (i + 1)).show();
if (i + 2 == count)
$(submmitButtonName).show();
selectStep(i + 1,'next');
});
}
有任何想法吗?
推荐答案
好,如果有人想知道...,我已经设法解决了我的问题.
Ok I've managed to solve my problem if anyone else would like to know...
function createNextButton(i) {
var stepName = "step" + i;
$("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>");
$("#" + stepName + "Next").bind("click", function(e) {
if (options.validationEnabled) {
var stepIsValid = true;
$("#"+stepName+" :input").each(function(index) {
checkMe = element.validate().element($(this));
//stepIsValid = !element.validate().element($(this)) && stepIsValid;
stepIsValid = checkMe && stepIsValid;
});
alert("stepIsValid === "+stepIsValid);
if (!stepIsValid) {
return false;
};
};
$("#" + stepName).hide();
$("#step" + (i + 1)).show();
if (i + 2 == count)
$(submmitButtonName).show();
selectStep(i + 1,'next');
});
}
这篇关于在字段集之间验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文