I'm using a jquery smart wizard script to make my forms into wizards.
This works very well, but the validation code looks like it could be made simpler.
This is the example they provide. Could this be made into a loop so I don't have to write it for each of my 5 steps ?
function validateSteps(step){
var isStepValid = true;
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('hideMessage');
$('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
}
}
if(step == 3){
if(validateStep3() == 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('hideMessage');
$('#wizard').smartWizard('setError',{stepnum:step,iserror:false});
}
}
return isStepValid;
}
Thanks
validateStep1()andvalidateStep2(), ..... so on, looks like! so can generalize it.