I am working on this wizard that have 5 steps but a single form, the intent is to process the data on a single server request when the user hits the Finish button.
I am trying to use Jquery Validate plugin to validate each step separately, my original idea was to reinitialize the plugin every time the user clicks next, like that:
function validateStepOne(){
$("#form").validate({
rules: {
x: "required"
}});
if(!$("#form").valid()){
return false;
}
return true;
}
function validateStepTwo(){
$("#form").validate({
rules: {
y : "required",
}});
if(!$("#form").valid()){
return false;
}
return true;
}
But that doesnt seems to work because on second+ steps the forms is always marked as valid, so I am wondering how can I reset the validation plugin to be able to validate the same form more than once.. Any help is welcome