If two separate input fields need to be validated together as well as
individually, what is the best way to do this? For example, I have a
'date' field and 'time' field. Both fields need to have valid date &
time, cannot be empty, and in addition, the value of the two fields
combined, cannot occur in the past.

I've tried it with 'groups' as well as a custom validation method via
'addMethod', but the error display mechanism doesn't behave similar to
how the other validation fields. Normally after the error is shown for
a specific field, the error highlight will disappear as the user fixes
the data without leaving the input field (ie, change/blur events
haven't been fired).

In my case, fixing one of the fields still leaves the other in the
group with the error highlight when I am expecting both to lose it as
they were highlighted together as soon as custom validation rule
failed. The only way to remove the error highlight is if you switch to
that field and have it lose focus.

Is there a way to have it so that that both fields in the group lose
the highlight as soon as either is corrected and meets the constraint
rule?

The custom validation method returns true or false depending on
whether the two fields meet the specific constraint and the only
option that I provide to the validator is 'submitHandler' so I haven't
changed any of the default error display mechanisms. All of validation
rules are set as classes on the form's input fields.

Thanks,
Shiney

Reply via email to