title: jquery - Numeric Only Text Field
body: <p>I found this very short clean code to only allow numeric chars in a text field.  Currently it only covers numbers 0-9 and backspace and delete.  I wanted it to also include decimal/period, so I have been fighting with this to simply include keycode 110 and/or 190.  I can not get it to work.  Can anyone see what I am doing wrong?</p>
  
  <pre><code>$(document).ready(function() {
      $('input.numberinput').bind('keypress', function(e) { 
  return ( e.which!=8 &amp;&amp; e.which!=0 &amp;&amp; (e.which&lt;48 || e.which&gt;57) ) || (e.which!=110) ? false : true ;
    });
    });
  </code></pre>
  
  <p><strong>jsfiddle here</strong>: <code>http://jsfiddle.net/justmelat/EN8pT/</code></p>
  
  <p><strong>html</strong>
      </p>
  
  <pre><code>         &lt;div class="label"&gt;Enter a number:&lt;/div&gt;
          &lt;input type="text" name="txtNumber1" id="txtNumber1" value=""  class="numberinput" /&gt;
  
           &lt;div class="label"&gt;Enter a number:&lt;/div&gt;
          &lt;input type="text" name="txtNumber2" id="txtNumber2" value="" class="numberinput" /&gt;
      &lt;/div&gt;
  </code></pre>