我在我的項目中使用智能嚮導讓用戶在我的網站上註冊。但是我想在步驟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();
}
我做到了以另一種方式,並嘗試過這種方式。謝謝。 – koli