[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-13 Thread Sam
How to change the default position of an error message in Jquey form validation plugin? This is easy to do. Just create a label element where you want the error message to appear. If the field you are validating is called foo your label would look like: label for=foo class=errorThis field is

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Don Dunbar
Hi , I double checked on javascript's XOR operator and it only works with bitwise: so you will have to write your own XOR . This isn't hard : [code] if (!foo != !bar) [\code] should work for all elements. or this [code]if( ( foo !bar ) || ( !foo bar ) )[\code] For the validator method

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Satyakaran
whats the problem? just check one field, it it is filled then do not check other. may be your problem is something else On Oct 11, 8:37 am, 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

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Phper
I am not familiar with the syntax of Jquery plugin. On Oct 12, 2:19 pm, Don Dunbar salemd1s...@gmail.com wrote: Hi , I double checked on javascript's XOR operator and it only works with bitwise: so you will have to write your own XOR . This isn't hard :   [code] if (!foo != !bar)  [\code]

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Don Dunbar
I thought of a much simpler solution. If possible could you use radio buttons for those two choices in your HTML? In a radio button group selecting one automatically deselects other buttons in the group. Then you could just use one of the built in validation checks, as you already have done, to

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Phper
No, I can not use radio. At the help of a veteran programmer, I was able to write the following code and it works. script type=text/javascript src=http://code.jquery.com/jquery- latest.js/script script type=text/javascript src=http://dev.jquery.com/view/trunk/

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Gordon
If you're using the Metadata plugin and inline rules: input type=text id=a class={validate:{required:'#b:blank'}} / input type=text id=b class={validate:{required:'#a:blank'}} / I've not actually tested it but it should work. On Oct 11, 4:37 am, Phper hi.steven...@gmail.com wrote: There are

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Phper
How to change the default position of an error message in Jquey form validation plugin? On Oct 12, 4:33 pm, Gordon grj.mc...@googlemail.com wrote: If you're using the Metadata plugin and inline rules: input type=text id=a class={validate:{required:'#b:blank'}} / input type=text id=b

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Phper
Also, how to prevent a user filling out both fields? On Oct 12, 4:48 pm, Phper hi.steven...@gmail.com wrote: How to change the default position of an error message in Jquey form validation plugin? On Oct 12, 4:33 pm, Gordon grj.mc...@googlemail.com wrote: If you're using the Metadata

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Phper
Also, how to prevent a user filling out both fields? On Oct 12, 4:48 pm, Phper hi.steven...@gmail.com wrote: How to change the default position of an error message in Jquey form validation plugin? On Oct 12, 4:33 pm, Gordon grj.mc...@googlemail.com wrote: If you're using the Metadata

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread d...@amystdesign.com
It will be confusing for someone filling out your form if you leave both fields available at the same time, instead... when the user enters text into one of the fields why don't you run an onChange or onKeyPress check to see if they've entered something and if so, disable/hide the other field

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-12 Thread Don Dunbar
Hi, glad you found a solution:to prevent the user from filling out both inputs in the first place. [code]$(#days).change(function(){ $(#participations).attr(disabled,disabled); }); $(#participations).change(function(){ $(#days).attr(disabled,disabled); }); [\code]

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-11 Thread Don Dunbar
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

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-11 Thread Phper
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

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-11 Thread Don Dunbar
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

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-11 Thread Phper
A good clue. But I still don't know where to write the if statement. It would be good if you can give me an example. On Oct 11, 10:57 pm, Don Dunbar salemd1s...@gmail.com wrote: Hi, if you are using the validation plugin, I believe it has a function addMethod that allows you to write your own

[jQuery] Re: Only one of two fields is required. How to implement this logic in Jquery form validation?

2009-10-11 Thread Phper
script type=text/javascript src=http://code.jquery.com/jquery- latest.js/script script type=text/javascript src=http://dev.jquery.com/view/trunk/ plugins/validate/jquery.validate.js/script script type=text/javascript !-- $(document).ready(function() { $(#form1).validate({ rules: {