IE reads JavaScript AND as an OR

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    #1

    IE reads JavaScript AND as an OR

    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/

    Code:
    function validate_form ( )
    {
        valid = true;
    
        if ...
    
    ... else if  (( document.quote_form.source.value == "Other" ) && ( document.quote_form.other.value == "" ))
        {
    	    alert ( "Please tell us how you found us." );
    	    valid = false;
        }
    
        return valid;
    }
    Am I missing something here?
  • ariful alam
    New Member
    • Jan 2011
    • 185

    #2
    Can you write a full example here. you wrote with missing area. please write a complete sample code.

    Thanks

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      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.

      Comment

      Working...