Hi Jörn, On Apr 13, 1:01 pm, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > Bryce Lohr schrieb:> Hi Jörn, > > 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 buttonvalidatethe 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!"); > }); > }); >
Thanks for this idea! That did the trick. I feel kind of silly now I didn't think of this simple solution the first time around. :) > > 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. > I definitely need this functionality, so I'm going to try to implement it. Could you explain a bit more about how I should subclass the validator? I don't understand subclassing in a JavaScript context all that well. I don't think I'd have a problem writing the code, but I'm not quite sure what I should change in the plugin & init part of the code. Thanks again for the hints! Bryce Lohr > Jörn