title: checking for integer input on button click
body: <p>I am trying to get this Javascript in my application working.</p>
  
  <pre><code>function validateQuantity(field)
  {
      var value = field.value; //get characters
      //check that all characters are digits, ., -, or ""
      for(var i=0;  i &lt; field.value.length; ++i)
      {
          var new_key = value.charAt(i); //cycle through characters
          if(((new_key &lt;= "0") || (new_key &gt; "9")) &amp;&amp;
              !(new_key == ""))
          {
              alert("Please enter number and greater than 0 only");
              return false;
              break;
          }
          return true;
      }
  }
  </code></pre>
  
  <p>And I have a input button as below</p>
  
  <pre><code>&lt;input class="buttonToLink" type="submit" value="Update" 
         onclick="return validateQuantity(document.getElementById('quantity'))"/&gt;
  </code></pre>
  
  <p>The above code successfully checks the input of all alphabet such as "abc" or alphabet and numeric such as "abcd123" as false. </p>
  
  <p>However, when I put numeric characters first, along with alphabet such as "123abc", it fails -- it does not show the alert.</p>
  
  <p>What did I do wrong with the code, and how can it be fixed?</p>