homepage Welcome to WebmasterWorld Guest from 54.211.68.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
multiple fields- must select at least one
Gilead



 
Msg#: 4382262 posted 8:03 pm on Nov 1, 2011 (gmt 0)

I'm validating form data. Got everything working with one exception.

field:phone
field:mobile
field:other
field:fax

User must fill out at least one of the contact fields.

if ((theForm.phone.value== "") && (theForm.mobile.value== "") && (theForm.other.value== "") && (theForm.fax.value == ""));
{
alert("Please enter a contact number in at least one field.");
theForm.phone.focus();
return (false);
}
Have tried both && and || but simply goes the the alert and the form breaks. What am I doing wrong here?
Thanks!

 

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4382262 posted 10:42 pm on Nov 1, 2011 (gmt 0)

Try removing the ; from the end of the if statement.

Gilead



 
Msg#: 4382262 posted 2:07 pm on Nov 2, 2011 (gmt 0)

Thanks! Completely missed that one. Works now.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved