I have a feature request / and/or bugfix depending on how you'd like
to look at the problem.

I have a section of a form that is toggled to/from a disabled state
based on another control.  For the sake of the example, if the
'authentication' checkbox is checked, then a 'username' and 'password'
text boxes become enabled, and are required fields.  These fields also
have additional validation rules.

This works totally fine w/ the validation rules as expected when
clicking on a submit button.

However, in an effort to make the form a little more interactive, I
need to clear any previous errors in the UI when the checkbox is
unchecked (which disables username and password).  Those text boxes no
longer need of validation as they will not be submitted.  Of course,
they also need to be reshown when the text boxes enter an enabled
state again if the checkbox is set.

In my "change" binding, I can do a validator.element(el) on each text
box to cause validation and theoretically clear the 'highlight'
state.  Unfortunately though, the check function does not monitor the
disabled state of the element.

At line 476 of version 1.5.5, add this line of code to the check
function -
if (element.disabled) return true;

Yes, this is redundant based from the perspective of validating the
whole form as disabled controls aren't included in the jQuery
selector... however, I think this check should be performed since any
element could theoretically passed to this public facing method.

I haven't done a ton of testing yet, but in my experience, this
effectively clears the error state on the dynamically disabled control
properly.



Additionally, it would be useful to have a method on the validator
that can be called on a jQuery collection that will clear the
'highlight' error state -- but that's not totally necessary with the
above fix.



Thanks

Reply via email to