The required: "selector, selector" variant is an OR selector. If one
of those matches, the field is required. Use a function instead to
implement AND.

Jörn

On Wed, Oct 29, 2008 at 3:49 PM, carter <[EMAIL PROTECTED]> wrote:
>
> I have a feedback form where if the user checks the 'Reply required'
> checkbox (replyCB) then they must complete either the email field
> (emailTF) or the phone field (phoneTF). I've searched through a lot of
> posts and tried some different ways of doing this with the validation
> plug in but can't get it to work successfully. In fact I'm having
> difficulty getting the :blank rule to work at all. My validation
> script is below. Any ideas where I'm going wrong?
>
> Thanks in advance.
>
> $().ready(function() {
>
>        // validate signup form on keyup and submit
>        $("#addComment").validate({
>                rules: {
>                        nameTF: "required",
>                        commentsTA: "required",
>                        emailTF: { /*if the reply box is checked and the phone 
> field is
> blank ask for an email address*/
>                                required: "#replyCB:checked, #phoneTF:blank",
>                                email: true
>                        },
>                        phoneTF: { /*if the reply box is checked and the email 
> field is
> blank ask for a phone number*/
>                                required: "#replyCB:checked, #emailTF:blank"
>                        }
>                },
>                messages: {
>                        nameTF: "* Required",
>                        commentsTA: " * Required",
>                        emailTF: " * Required",
>                        phoneTF: " * Required"
>                }
>        });
> });
>

Reply via email to