title: Javascript number comparison fails
body: <p>I'm trying to understand where is my error, because it's not possible that JS fails in math!</p>
  
  <p>On the HTML form I have a select and 9 text input.
  Then, on the JS I compare the text entered.</p>
  
  <p>My problem is the following:
  If I write on</p>
  
  <pre><code>new_da3 = 1400
  new_a3 = 1900
  </code></pre>
  
  <p>the JS will say ok3.</p>
  
  <p>If I write on</p>
  
  <pre><code>new_da3 = 1900
  new_a3 = 1400
  </code></pre>
  
  <p>the JS will say no3!</p>
  
  <p>BUT If I write on</p>
  
  <pre><code>new_da3 = 1500
  new_a3 = 800
  </code></pre>
  
  <p>the JS WILLL SAY ok3!</p>
  
  <p>Why? Isn't 1500 bigger than 800?</p>
  
  <p>Thank you!</p>
  
  <p>HTML:</p>
  
  <pre><code> &lt;form&gt;
   &lt;select id="new_nrp" onchange="selNrP(this.value);" style="background-color:#F00; color:#FFF"&gt;
              &lt;option value="" selected="selected"&gt;&lt;/option&gt;
              &lt;option value="1"&gt;1&lt;/option&gt;
              &lt;option value="2"&gt;2&lt;/option&gt;
              &lt;option value="3"&gt;3&lt;/option&gt;
          &lt;/select&gt;
  
      &lt;?php
      for($i=1; $i&lt;=3; $i++){
          print '&lt;input type="text" size="5" maxlength="5" id="new_da'.$i.'"&gt;
                 &lt;input type="text" size="5" maxlength="5" id="new_a'.$i.'"&gt;';
  
      }
      ?&gt;
  
      &lt;input type="submit" class="buttongreen" onClick="test()" value="Try the test function!"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function test(){
      var new_da1 = document.getElementById('new_da1').value
  var new_a1 = document.getElementById('new_a1').value
  var new_da2 = document.getElementById('new_da2').value
  var new_a2 = document.getElementById('new_a2').value
  var new_da3 = document.getElementById('new_da3').value
  var new_a3 = document.getElementById('new_a3').value
  
  var new_nrp = document.getElementById('new_nrp').value
  
  switch(new_nrp){
      case '3':
          if(new_a2 &lt; new_da3 &amp;&amp; new_da3 &lt;= new_a3){
              alert('ok3')
          } else {
              alert('no3')
              return
          }
      case '2':
          if(new_a1 &lt; new_da2 &amp;&amp; new_da2 &lt;= new_a2){
              alert('ok2')
          } else {
              alert('no2')
              return
          }
      case '1':
          if(new_da1 &lt;= new_a1){
              alert('ok1')
          } else {
              alert('no1')
              return
          }
      break;
      default:
          alert("Why are you here?");
          return;
  }
  
  }
  </code></pre>