This worked great! Thanks Josh!
For anyone else that may need this, here is the code I used:
$(document).ready(function() {
$("#contactForm").validate({
rules: {
namevalid: {
required: function() {
return $('#nameFirst').val() || $('#nameLast').val()
}
}
},
messages: {
namevalid: "First or last name required"
}
});
});
<input type="hidden" name="namevalid" value=""/>
<p>First Name</p>
<input name="nameFirst" id="nameFirst" maxlength="50" type="text" />
<p>Last Name</p>
<input name="nameLast" id="nameLast" maxlength="50" type="text" />
On May 14, 11:39 am, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> >> I have two fields (for sake of argument) and before the form is valid
> >> at least one field must be filled in. They are nameFirst and nameLast.
>
> I think one time I accomplished this by creating a "dummy" hidden input
> field that is only used for the validation. You can set up this dummy field
> so that validation fails if your OR condition is not met. I don't have the
> syntax in front of me but it's something like...
>
> dummy: { required: function() { return $('#field1').val() ||
> $('#field2').val() } }
>
> Then you'll have to do the error placement in the right place.
>
> -- Josh
>
> ----- Original Message -----
> From: "TheDudeAbides" <[EMAIL PROTECTED]>
> To: "jQuery (English)" <[email protected]>
> Sent: Wednesday, May 14, 2008 7:12 AM
> Subject: [jQuery] Re: JQuery Validator OR Operater
>
> > I'm going to give this a little bump to see if anyone has any ideas.
>
> > Thanks!
>
> > On May 9, 11:26 am, TheDudeAbides <[EMAIL PROTECTED]> wrote:
> >> Hello Everyone,
>
> >> I've done some searching and am unable to find information on using an
> >> ORoperatorin the JQuery Validator plugin.
>
> >> I have two fields (for sake of argument) and before the form is valid
> >> at least one field must be filled in. They are nameFirst and nameLast.
>
> >> There may be a simple answer to this but I am just lost. I am
> >> competent enough with the Validator plugin to setup comparison rules,
> >> length rules, etc. just haven't been able find any ORoperator
> >> information yet.
>
> >> Any help is greatly appreciated! Thanks!
>
> >> Jimmy