字段集之间的验证
我正在使用带有低音验证的 formtowizard jquery 插件。我已将下一个按钮附加到验证我的表单的单击事件,但是我只希望它验证当前字段集而不是整个表单...
我的表单设置如下
<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();
});
这是我的按钮在哪里被调用
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');
});
}
有人有什么想法吗?
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...
My form is set up like this
<form id="SignupForm" method="POST" action="..................">
<fieldset>
<legend>Application</legend>
<div>
</div>
</fieldset>
<fieldset>
<legend>Step Two</legend>
<div>
</div>
</fieldset>
This is what I'm using at the moment
$("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');
});
}
Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我已经成功解决了我的问题,如果其他人想知道的话......
Ok I've managed to solve my problem if anyone else would like to know...