Is it possible to validate one required with two text boxes? I need the user to either enter in a phone number or an email address or both before submitting the form. Cant seem to get this to work properly allthough the tooltip says that it would work with textbox/radio elements.
Here is my form code:
In line 7 of validation I have : email
In line 12 of validation I have: phone, email
Any help?
Thank you in advance
Here is my form code:
<label>Phone Number
<input type="text" name="phone" id="phone" />
</label>
<label>Email Address
<input type="text" name="email" id="email" />
</label> <br /><br />
<input type="submit" name="submit" id="submit" value="Submit" />
In line 7 of validation I have : email
In line 12 of validation I have: phone, email
Any help?
Thank you in advance
HI ksimba,
Wrap the two fields in a div, remove the entries from line 12 of the validation and manually enter the class in the last input of the group.
Bob
Wrap the two fields in a div, remove the entries from line 12 of the validation and manually enter the class in the last input of the group.
<div>
<label>Phone Number
<input type="text" name="phone" id="phone" />
</label>
<label>Email Address
<input type="text" name="email" id="email" />
</label> <br /><br />
<input type="submit" name="submit" id="submit" class='validate-one-required' value="Submit" />
</div>
That should work OK, though I've never tried it with inputs.Bob
Hi, I think this rule will not happen unless the fields are with the same names, and you can't do this with buttons I think too!
Regards
Max
Regards
Max
Ok, I removed the code from the button and gave the elements the same name and still no luck. Any other suggestions? I am sure that some one has done this before. I just need to be sure that the form does not submit any blank values. The user should enter in a phone number or an email address or both. :?
Hello Guys, thank you for your help but I went right to the source and I was able to find some help with this post:
http://groups.google.com/group/dexagogo/browse_thread/thread/3761b845251eef12/a3baf1f243a3aace?lnk=gst&q=validate+one+required+text#a3baf1f243a3aace
I will let you know how it goes when I have time to implement it. I am going to sleep now, it is 6am on my side of the world. 😀
http://groups.google.com/group/dexagogo/browse_thread/thread/3761b845251eef12/a3baf1f243a3aace?lnk=gst&q=validate+one+required+text#a3baf1f243a3aace
I will let you know how it goes when I have time to implement it. I am going to sleep now, it is 6am on my side of the world. 😀
Hi ksimba,
I hope you slept well!
I was taking a look at this until our power went off for a couple of hours :-(
It looks to me as though the function was not well ported over from Prototype to MooTools . . . I'll look again when I've cought up with myself.
Bob
I hope you slept well!
I was taking a look at this until our power went off for a couple of hours :-(
It looks to me as though the function was not well ported over from Prototype to MooTools . . . I'll look again when I've cought up with myself.
Bob
Hi ksimba,
Not idea but I think this version work OK. I've added some ids and extra classes to your Form HTML.
Bob
Not idea but I think this version work OK. I've added some ids and extra classes to your Form HTML.
<div>
<label>Phone Number
<input type="text" name="phone" id="phone" class='email' value='' />
</label>
<label>Email Address
<input type="text" name="email" id="email" class='validate-1req email' value=''/>
</label>
</div><br /><br />
<input type="submit" name="submit" id="submit" value="Submit" />
and then this validation code needs to go into the JavaScript Box. // add the new validator to the validators
Validation.add('validate-1req',
'Please select one of the above options.',
function (v,elm) {
var options = $$('.'+elm.id.toString());
for( i = 0; i < options.length; i++ ){
if(options[i].value) {
return true;
}
}
});
This checks for any other inputs with classes the same as the id of the field with the validation class. Here that's 'email' so we've added the 'email class to both inputs. It should work with any number of text inputs in any order.Bob
Hello Bob,
After copying the code just as you have it and adding it per your directions, I still cant get it to properly validate. Everything looks right and makes sense but just wont act right *grrr* Any more suggestions? I even turned off the validation option in chronoforms thinking that there was a conflict but still no luck. The only other JavaScript being called is for swmenupro but even when disable the menu, It still doesnt validate. 😟
After copying the code just as you have it and adding it per your directions, I still cant get it to properly validate. Everything looks right and makes sense but just wont act right *grrr* Any more suggestions? I even turned off the validation option in chronoforms thinking that there was a conflict but still no luck. The only other JavaScript being called is for swmenupro but even when disable the menu, It still doesnt validate. 😟
Bob, we have a saying here in the US and it is: YOU ARE THE MAN!!! The code would not work when placed in the JavaScript box within chronoforms but when I added it directly to the validation.js, it worked like a charm. I think that is all I needed. Thank you so very much!
Hi ksimba,
Excellent, 'm sure that the code could be more elegant but if it works OK . . .
Bob
PS No idea why it wouldn't work for you in the JavaScript - I developed it in there and it worked OK. Maybe there is some other tweak in my MooValidation file that I've forgotten about.
Excellent, 'm sure that the code could be more elegant but if it works OK . . .
Bob
PS No idea why it wouldn't work for you in the JavaScript - I developed it in there and it worked OK. Maybe there is some other tweak in my MooValidation file that I've forgotten about.
This topic is locked and no more replies can be posted.