title: Allow only Numbers in text box using jquery with out extra plugins
body: <p>i wanted to Allow only Numbers in text box using jquery/javascript with out extra plugins</p>
  
  <p>I have coded like :</p>
  
  <pre><code>if ( event.keyCode == 46 || event.keyCode == 8 || (event.keyCode &gt;=48 &amp;&amp; event.keyCode &lt;=57)) {
              // let it happen, don't do anything
          }
          else {
              // Ensure that it is a number and stop the keypress           
              event.preventDefault();                   
          }
  </code></pre>
  
  <p>but it allows special characters like ! (Shift+1), @ (shift +2) etc. </p>
  
  <p>can any body tell me the complete solution for this .. thanks in advance</p>