title: Block numbers from being entered in an input field
body: <p>Okay, first some background, I can't use any javascript library except YUI for this project.</p>
  
  <p>What I'm trying to do is take an input and block it to only allow numeric input. I know this is easier to just do in validation, but the PM wants it onkeypress. What I have was constructed from running around the net and works great in firefox. Unfortunately, this has to be compatible with IE8 and IE6, and it works in neither.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function onlyNumbers(evt) {
          evt = (evt) ? evt : window.event
          var charCode = (evt.which) ? evt.which : event.keyCode        
  
          if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
              return false;
  
          return true;
  
      }
  &lt;/script&gt;
  &lt;input type="text" id="&lt;%=Model.HtmlID %&gt;" value="&lt;%= startingAnswer %&gt;"name="&lt;%=Model.HtmlID %&gt;"
   maxlength="&lt;%=maximumLength %&gt;" onkeypress="return onlyNumbers(event);" /&gt;
  </code></pre>
  
  <p>Any ideas on what is wrong with it that is making it not work in IE?</p>