title: How do I restrict a text input to numbers only but allow numbers from a 10 key?
body: <p>I am confused why I am not able to use the 10 key to input numbers.</p>
  
  <p>The following example auto fills the "/".  I tried a few different ways to adjust the regex on it, but when I do, I can't backspace or delete anything past the last "/".  (01/01/2000 ... 01/01/ &lt;- won't let me delete past this).</p>
  
  <pre><code>       $('#date').keydown(function (e) {
              var key = e.charCode || e.keyCode || 0;
              $date = $(this);
  
              if (key !== 8) {
                  var regex = new RegExp("^[0-9\t/]");
                  var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
                  if (!regex.test(key)) {
                     event.preventDefault();
                     return false;
                  }
  
                  if ($date.val().length === 0) {
                      $date.val($date.val() + '');
                  }
                  if ($date.val().length === 2) {
                      $date.val($date.val() + '/');
                  }
                  if ($date.val().length === 5) {
                      $date.val($date.val() + '/');
                  }
              }
          }); 
  </code></pre>
  
  <p>Please help me find a way where it continues to auto-format the  "/" as it does now but restricts to numbers only (except the required "/") and allows me to use the 10 key numbers.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thank you in advance.</p>