title: stop immediate action with jQuery keyup
body: <p>I want to just allow 0-9 keys and backspace key to be inputted by user in some textbox and want to not allow others. I have tried this but this is not working..</p>
  
  <pre><code> $('#UnitDistance').on('keyup', function (event) {
      var x = event.keyCode;        
      if (x != 8 || x &lt; 48 || x &gt; 57) {  // 48-57 is the code for key 0-9 .. 8 is backspace                      
          $('#UnitDistance').val('');
   });
  </code></pre>
  
  <p>Is there any better ideas doing so.</p>