jQuery Validate - Require at least one from group, plus additional items.

Posted by Kevin Pullin on Stack Overflow See other posts from Stack Overflow or by Kevin Pullin
Published on 2010-05-30T00:48:17Z Indexed on 2010/05/30 0:52 UTC
Read the original article Hit count: 256

Filed under:
|

I'm attempting to use 'jQuery Validate' on a form that requires an email address plus either all items of a shipping address completed or none at all.

Using the sample provided by the solution to this question: jQuery Validate - “Either skip these fields, or fill at least X of them”, I have been able to successfully solve the validation of the address group.

The problem, however, is that the logic for validating the email address field does not work. From debugging the Validate scripts, the "re-entrant" validation code triggered by calling 'fields.data('being_validated', true).valid();' in the linked example results in a reset of all previously validated errors (i.e. the email validation error is cleared).

I have modified some existing samples, the first in which removes the offending line and the second with it included.

Email Validation Working

Email Validation Fails

Any tips or suggestions on how to properly solve this or work around the failure?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-validate