acctman Posted April 30, 2009 Share Posted April 30, 2009 can someone explain why this is not working? I'm not getting any errors. i'm assuming its my AND and OR statements. I work it just like I would do in php. It works fine if i just have the regular If statement without the AND or OR <script type="text/javascript"> function validate(form) { var city = document.getElementById('city').value; var ethnicity = document.getElementById('ethnicity').value; var zip = document.getElementById('zip').value; var country = document.getElementById('country').value; var state_3 = document.getElementById('state_3').value; var state_2 = document.getElementById('state_2').value; if(city == "") { inlineMsg('city','<strong>Error:</strong><br />Enter your city.',6); return false; } if(ethnicity == "") { inlineMsg('ethnicity','<strong>Error:</strong><br />Select your ethnicity.',6); return false; } if(country == "US" || "CA" && zip == "") { inlineMsg('zip','<strong>Error:</strong><br />Input your zipcode US/CAN.',6); return false; } if(country == "") { inlineMsg('country','<strong>Error:</strong><br />Select your country.',6); return false; } if(country == "US" && state_3 == "") { inlineMsg('state_3','<strong>Error:</strong><br />Select your state.',6); return false; } if(country == "CA" && state_2 == "") { inlineMsg('state_2','<strong>Error:</strong><br />Select your province.',6); return false; } return true; } </script> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 if(country == "US" || "CA" && zip == "") { inlineMsg('zip','<strong>Error:</strong><br />Input your zipcode US/CAN.',6); return false; } That works if you convert that into PHP? o.O Try this: if((country == "US" || country == "CA") && zip == "") { inlineMsg('zip','<strong>Error:</strong><br />Input your zipcode US/CAN.',6); return false; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.