Javascript jQuery多步骤验证
我正在使用jqueryvalidate插件创建一个多步骤表单,我正在为下一步的验证而努力 如果我隐藏表单的其他步骤,则验证工作正常,但当您通过某个步骤时,验证就不工作了。例如,验证在步骤1中工作,但当您到达步骤2并单击“下一步”时,它将忽略验证 这就是我目前拥有的:Javascript jQuery多步骤验证,javascript,jquery,validation,Javascript,Jquery,Validation,我正在使用jqueryvalidate插件创建一个多步骤表单,我正在为下一步的验证而努力 如果我隐藏表单的其他步骤,则验证工作正常,但当您通过某个步骤时,验证就不工作了。例如,验证在步骤1中工作,但当您到达步骤2并单击“下一步”时,它将忽略验证 这就是我目前拥有的: $("a#step1_button").on("click", function(e){ // Validation // $('#application_form_form').validate({
$("a#step1_button").on("click", function(e){
// Validation //
$('#application_form_form').validate({
rules: {
first_name: "required",
last_name: "required"
},
messages: {
first_name: "Please answer this question",
last_name: "Please answer this question"
},
ignore: ".ignore"
});
if ( $('#application_form_form').valid() == true ) {
$('#step1').slideUp(500);
$('#step2').delay(700).slideDown(500);
} else {
e.preventDefault();
}
});
$("a#step2_button").on("click", function(e){
// Validation //
$('#application_form_form').validate({
rules: {
reference_first_name: "required",
reference_last_name: "required"
},
messages: {
reference_first_name: "Please answer this question",
reference_last_name: "Please answer this question"
},
ignore: ".ignore"
});
if ( $('#application_form_form').valid() == true ) {
$('#step2').slideUp(500);
$('#step3').delay(700).slideDown(500);
} else {
e.preventDefault();
}
});
有谁能帮我解决这个问题,并告诉我如何解决这个问题吗
非常感谢。$(“a#step2_按钮”)。在(“单击”上,函数(e)将其替换为$('body')。在('click','a#step2_按钮')上,函数(e)感谢您在这方面的帮助-我已经更改了此项,不幸的是,在第2步的验证工作中没有显示。有人对此有任何想法吗?