title: How to allow numbers, backspace, delete, left and right arrow keys in the html text?
body: <p>I am using following javascript code which I think should only allow numbers, backspace, delet, left arrow and right arrow keys in textbox, but it is also allowing alphabets. I don't know why?</p>
  
  <pre><code>function validateQty(event) {
      var key = window.event ? event.keyCode : event.which;
  
  if (event.keyCode == 8 || event.keyCode == 46
   || event.keyCode == 37 || event.keyCode == 39) {
      return true;
  }
  else if ( key &lt; 48 || key &gt; 57 ) {
      return false;
  }
  else return true;
  };
  </code></pre>
  
  <p>Calling this function as</p>
  
  <pre><code>&lt;input type="text" onkeypress='validateQty(event)'&gt;
  </code></pre>