Hi, if you are using the validation plugin, I believe it has a function
"addMethod" that allows you to write your own method for the validation. It
requires a name (javascript identifier), a method to check input against (
in your case A and B would be checked for completion) and a message to
display when there is an error (i.e. neither A nor B is filled out, or both
are). You can get the details for using the "addMethod" function at the
jQuery Docs page.
http://docs.jquery.com/Plugins/Validation
The page lists demos and the function you need is toward the bottom of the
page.

The logic is fairly straight forward :  when the form is being filled out
listen for when A and B have focus, remember if either is checked or ignored
and check to make sure both are not simultaneously filled out. Check this on
submit as well.

Good luck,
DED

On Sun, Oct 11, 2009 at 7:42 AM, Phper <hi.steven...@gmail.com> wrote:

>
> How can I write the code in the context of Jquery validate function?
>
> On Oct 11, 12:43 pm, Don Dunbar <salemd1s...@gmail.com> wrote:
> > Hi, javascript has an 'xor' operator. It works just like 'or' in an 'if'
> > statement except in 'xor' only one side can be true. In a normal 'or'
> > statement either side can be true or both can. So you probably want to do
> > something like: if ( A XOR B) { } .  Then only one can be true to
> continue
> > if both are true the statement returns 'false'.Hope this helps.
> > DED
> >
> > On Sat, Oct 10, 2009 at 10:37 PM, Phper <hi.steven...@gmail.com> wrote:
> >
> > > There are two input fields in a form, but only one of them is
> > > required, they are not required at the same time. Either A or B is
> > > required. ( A is required  OR B is required). In other words, a user
> > > can input data to field A, or he can input data to filed B, but he can
> > > not input data to Both A and B at the same time.
> >
> > > How to implement this constraint in Jquery form validation?
>

Reply via email to