jQuery Validation Plugin (.validate) -- multi-page form validation with "pageRequired" method

jQuery Validation Plugin (.validate) -- multi-page form validation with "pageRequired" method

Hi all,

I'm using the jQuery Validation Plugin with a multi-part form. I coded it based on the the multipart form example ( http://jqueryvalidation.org/files/demo/multipart/), which includes a custom method so that only the current page is validated when advancing through the form.

When trying to wrap my head around the sample code (below) I noticed that only the current page validates even if you don't add the pageRequired identifier to the form inputs. It's not just in my code: I replaced every instance of "pageRequired" in the sample code with "required" and still only the current page validates.

Obviously I am missing something. Anyone can explain why the special method is not needed? Or is it?

Here's the sample current-page-only validation method (below) and here's a jsfiddle showing the sample seemingly working fine without any use of pageRequired: http://jsfiddle.net/uLuxyp7u/.

Thanks for any help.

$.validator.addMethod("pageRequired", function(value, element) {
var $element = $(element)
function match(index) {
return current == index && $(element).parents("#sf" + (index + 1)).length;
}
if (match(0) || match(1) || match(2)) {
return !this.optional(element);
}
return "dependency-mismatch";
}, $.validator.messages.required)