jQuery表单向导验证 [英] jquery form wizard validation
问题描述
I'm trying to implement a validation script (bassistance) with a jquery form wizard (http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx) but I'm having some problems.
在jquery向导的页面上,一个名为"Tommy"的家伙提出了一段代码,以实现该代码的低音增强功能.但是由于某种原因,我无法使其正常工作.出现这样的说法:是否需要填写该字段等等,而下一个按钮不起作用-很好,但是,如果我填写所有字段,则下一个按钮仍然不起作用.
On the page for the jquery wizard, a guy named "Tommy" came up with a piece of code to implement bassistance with the code. But for some reason I can't get it to work. It comes up saying if the field needs to be filled in etc and the next button doesn't work - which is fine, BUT, if I fill in all the fields, the next button still doesn't work..
function createNextButton(i) {
var stepName = "step" + i;
$("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next ></a>");
/* VALIDATION */
if (options.validationEnabled) {
var stepIsValid = true;
$("#" + stepName + " :input").each(function(index) {
stepIsValid = !element.validate().element($(this)) && stepIsValid;
});
if (!stepIsValid) {
return false;
}
}
/* END VALIDATION */
$("#" + stepName + "Next").bind("click", function(e) {
$("#" + stepName).hide();
$("#step" + (i + 1)).show();
if (i + 2 == count)
$(submmitButtonName).show();
selectStep(i + 1);
});
}
有人可以帮我解决这个问题吗? :)
Could someone help me figure this one out? :)
推荐答案
好,所以我将验证添加到click事件中,然后我发现"element.validate().element($(this))&& stepIsValid"实际上已经存在.如果其他任何人正在使用它并遇到相同的问题,则解决方法是:
Ok so I added the validation to the click event and I figured out that "element.validate().element($(this)) && stepIsValid" actually existed.. If anyone else is using this and having the same problem, the solution is:
/* 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;
};
};
/* END VALIDATION */
这篇关于jQuery表单向导验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!