Jquery validation, step by step validate on click function.
- by Alex
Trying to get jquery validation plugin work with my step by step form and here is the function i made. It works but only with first step. Any other step or final submit wont work in that case. If anyone could have a look whats wrong with my code i would appreciate the most.
Thank you.
function StepByStep(){
var a = {
rules: {
fieldname1: "required",
fieldname2: "required",
}
}
var b = {
rules: {
fieldname3:"required"
}
}
var aStep = $("form").validate(a);
var bStep = $("form").validate(b);
$('input.nextStep').click(function(){
if (aStep.form()) {
//open step 2 function
}
return false
});
$('input.submit').click(function(){
if (bStep.form()) {
$('form').submit();
}
return false
}); }