Bryce Lohr schrieb:
Hi Jörn,

I've put together some simplified example pages showing the two main
use cases I'm having a problem with. I created two versions of each
page, one using Validate 1.1.2, and one using Validate 1.2.1. The
1.1.2 example function properly, while the 1.2.1 versions don't.

Validating a subsection of a larger form:
http://www.gearheadsoftware.com/subsect-112.html
http://www.gearheadsoftware.com/subsect-121.html
You can solve that by setting up validation only once and switching rules when necessary, something like this:

$(function() {
           // Rules just for the Financial Info subsection
           var eligibilityRules = [...]

           // Set up validation on the whole form
           var validator = $("form").validate({rules: mainRules});

           // Make the button validate the subsection on click
           $("#eligCheck").click(function(evt) {

                validator.settings.rules = eligibilityRules;
                var valid = $("form").valid();
                validator.settings.rules = mainRules;
               // Set up validation, do it, and check results all at once
               if ( !valid ) {
return false; }

// There would actually be an AJAX submit & server validation // here
               alert("Eligible!");
           });
       });

Dynamically setting up validation for editable table rows:
http://www.gearheadsoftware.com/tableval-112.html
http://www.gearheadsoftware.com/tableval-121.html
This is way more complex, I don't have an immediate solution at hand.The validation plugin is designed around forms, which aren't available in this case.

A first idea that comes to mind is subclassing the validator object to use it for these rows. You'd have to write your own init/plugin code, but that shouldn't be much of a problem. Actual access to eg. element.form happens only in a few places, and these may not even be affected in this case.

Let me know if you try to implement that path and have any questions.

Jörn

Reply via email to