我在我的项目中使用 SmartWizard 来让用户在我的网站上注册。但我想在向导有四个步骤的第 3 步保存所有数据。向导在单击完成按钮后提交表单。下面的代码将描述我的假设,任何人都可以提出一种方法来做到这一点。谢谢。
function validateAllSteps(){
var isStepValid = true;
if(validateStep1() == false){
isStepValid = false;
$('#wizard').smartWizard('setError',{stepnum:1,iserror:true});
}else{
$('#wizard').smartWizard('setError',{stepnum:1,iserror:false});
}
if(validateStep2() == false){
isStepValid = false;
$('#wizard').smartWizard('setError',{stepnum:2,iserror:true});
}else{
$('#wizard').smartWizard('setError',{stepnum:2,iserror:false});
}
return isStepValid;
}
function validateSteps(step){
var isStepValid = true;
// validate step 1
if(step == 1){
if(validateStep1() == false ){
isStepValid = false;
$('#wizard').smartWizard('showMessage','Please correct the errors in step'+step+
' and click next.');
$('#wizard').smartWizard('setError',{stepnum:step,iserror:true});
}else{
$('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
}
}
// validate step 2
if(step == 2){
if(validateStep2() == false ){
isStepValid = false;
$('#wizard').smartWizard('showMessage','Please correct the errors in step'+step+
' and click next.');
$('#wizard').smartWizard('setError',{stepnum:step,iserror:true});
}else{
$('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
}
}
return isStepValid;
}
//start of step one validation
//end of of step one validation
//step 2 validation
//end of step 2 validation
var res=validateAllSteps();
if(res == true)
{
$('#form1').submit();
}