By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

IE reads JavaScript AND as an OR

KeredDrahcir
100+
P: 426
I have problem using Internet Explorer. I have a form that has the last question about asking the user how they found us. It gives a dropdown list with various options with the last option being Other. If they select Other a box appears for them to Specify.
I'm using JavaScript to validate the form so it looks at the dropdown and if the value of the dropdown is "Other" it looks at the box to see if it's blank.

This works fine in Firefox, Safari, Google Chrome and Opera but in Internet Explorer 8 (it works in Version 9) when I click submit it complains about the "Please Specify" box being blank, even when I don't choose Other.

I thought JavaScript was reading the AND statement as OR but I think is must be something else.

Can anyone help/

Expand|Select|Wrap|Line Numbers
  1. function validate_form ( )
  2. {
  3.     valid = true;
  4.  
  5.     if ...
  6.  
  7. ... else if  (( document.quote_form.source.value == "Other" ) && ( document.quote_form.other.value == "" ))
  8.     {
  9.         alert ( "Please tell us how you found us." );
  10.         valid = false;
  11.     }
  12.  
  13.     return valid;
  14. }
  15.  
Am I missing something here?
Jul 30 '12 #1

✓ answered by KeredDrahcir

It was only the section I included which was relevant. I've managed to sort it now. Often when I've used dropdown lists I haven't used a value element using the text that is displayed as the value but it seems IE needs the value in the JavaScript which makes sense although I don't know why it was needed if the other browsers managed.
Including a value in each of the dropdown options sorted the problem.

Is this a known case in IE.

Share this Question
Share on Google+
2 Replies


ariful alam
100+
P: 185
Can you write a full example here. you wrote with missing area. please write a complete sample code.

Thanks
Jul 30 '12 #2

KeredDrahcir
100+
P: 426
It was only the section I included which was relevant. I've managed to sort it now. Often when I've used dropdown lists I haven't used a value element using the text that is displayed as the value but it seems IE needs the value in the JavaScript which makes sense although I don't know why it was needed if the other browsers managed.
Including a value in each of the dropdown options sorted the problem.

Is this a known case in IE.
Jul 31 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.