I am trying to use the jQuery validation plugin (from here → http://bassistance.de/jquery-plugins/jquery-plugin-validation/) to programmatically validate fields in specific sections of a page based on a click on a button (and not in the form of the form submission to the end at the end of the section where it will validate the entire form) before moving to a new section. In fact, when you click a button in a specific section, the fields in this section should be checked. The first part of the page is checked just fine, but when I go to the second section, it just passes without checking. What is the right way to do this? Am I at least on the right track?
here is an example of what i'm talking about. If necessary, I can add more code.
var validateStep1 = $("#form1").validate({
errorClass: "warning",
onkeyup: false,
onblur: false,
onfocusout: true,
rules: {
"field1": {
required: true,
},
"field2": {
required: true,
minlength: 1
},
"field3": {
required: true,
}
}
});
var validateStep2 = $("#form1").validate({
errorClass: "warning",
onkeyup: false,
onblur: false,
onfocusout: true,
rules: {
"field4": {
required: true,
},
"field5": {
required: true,
},
"field6": {
required: true,
}
}
});
$("#button1").click( function() {
if (validateStep1.form()) {
}
});
$("#button2").click( function() {
if (validateStep2.form()) {
}
});
Thanks in advance for your help!