[jQuery] AjaxForm and Validate without window-level variables
Hello again all,
I'm attempting to use Mike Alsup's excellent AjaxForm plugin with Jörn
Zaefferer's handy Validate plugin, and so far I've had great success
setting up both, then hooking them together by returning the result of
Validate's .valid() method from beforeSubmit on the AjaxForm setup
(see example code link at the bottom). Basically, .valid() returns
boolean true or false, and that result gets returned from
beforeSubmit, halting the ajaxForm GET or POST. It works well, but to
keep track of the validator, I'm using a window-level variable --
oValidator = $("#formId".validate(...) -- since calling .valid() on
the $("#formId") object itself is not possible.
So, my question is, can I store the validator reference some other
way, without using a global variable such that it would work correctly
with, say, multiple forms on one page?
Here's the example code I'm working with:
http://www.command-tab.com/demos/ajaxform_validate/
Any suggestions would be appreciated! Thanks!