Hi The validator plugin contains errorList and errorMap properties. The erorrList contains the invalid elements and the respective messages and the errorMap contains the invalid element id and it's associated error message. Perhaps checking these will assist with determining the invalid element.
eg. if (validator.errorMap.selectElementId == 'undefined') { execute code} Using undefined since you have no errormessage to test against. Hope that helps... On Apr 3, 7:04 am, CrabMan <atcrabt...@gmail.com> wrote: > This makes it very difficult to determine which element is causing the > error and execute code in response. > > For instance, the following does not work, because there is no way to > determine which input caused the error because the errorClass has not > been set yet when invalidHandler is called: > > $('#step_1_form').validate({ > rules: { > category_selector: "required", > zip_code: "required" > }, > messages: { > category_selector: "" > }, > invalidHandler: function() { > if > ($('select[name^="category_selector"][class*="error"]').length > > 0) > { > // EXECUTE SOME CODE SPECIFIC TO THIS ERROR > } > } > > } > > A work around is to use setTimeout, but is obviously an undesirable > hack: > > $('#step_1_form').validate({ > rules: { > category_selector: "required", > zip_code: "required" > }, > messages: { > category_selector: "" > }, > invalidHandler: function() { > var displayErrors = function() { > if > ($('select[name^="category_selector"][class*="error"]').length > > 0) > { > // EXECUTE SOME CODE SPECIFIC TO THIS ERROR > } > }; > setTimeout(displayErrors,10); > } > > } > > Am I correct? or is there a better way to determine the element > causing the error, and regardless, shouldn't errorClass be set before > invalidHandler is called anyways?