title: Alow only Integer and Float values in Textfield
body: <p>I have a textfield of <strong>Price</strong>.</p>
  
  <p>I want only Integer and Float values in it.</p>
  
  <p>I have done the Integer. But it is not accepting Float values like : 3110.6</p>
  
  <p>Here is my Code <a href="http://jsfiddle.net/jVMUR/" rel="nofollow">DEMO</a></p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>$(document).ready(function () {
      $("#price").keydown(function (event) {
          // Allow only backspace and delete
          if (event.keyCode == 46 || event.keyCode == 8) {
              // let it happen, don't do anything
          } else {
              // Ensure that it is a number and stop the keypress
              if (event.keyCode &lt; 48 || event.keyCode &gt; 57) {
                  event.preventDefault();
              }
          }
      });
  });
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;input name="price" type="text" id="price"&gt;
  </code></pre>