title: How to make this Javascript function work in IE Browser?
body: <p>The purpose of this JAVSCRIPT function is to prevent users from entering any alpha characters.  If user enters those characters, the cursor does not move at all and stays at the same place. However if user enters a digit, cursor moves to the next position. </p>
  
  <p>For example, in this text field, I only allow users to enter digits only. This method is working fine in all browsers except IE 8 and earlier. I tested it on Firefox, Chrome, and Safari and even in Safari emulator with no issues.   If anybody guide me or even suggest me to modify my method so that it also works fine in IE that would be great help!!!  Thank you</p>
  
  <pre><code>function AllowOnlyDigit(e) {
       var ev = e || window.event;
       var key = ev.keyCode || ev.which || ev.charCode;
  
       if (key &gt; 31 &amp;&amp; (key &lt; 48 || key &gt; 57)) {
           return false;
       }
       return true;
   }
  </code></pre>
  
  <p>and this is how I am invoking this method : </p>
  
  <pre><code>&lt;input type="text" onkeypress="return AllowOnlyDigit(event)" /&gt;
  </code></pre>