title: Jquery asp.net textbox validation
body: <p>I need to validate a textbox using jquery to accept only 5 numeric characters. And it should be a valid number. Not like "00010". It should start with a natural number. The problem I am facing is i have enabled backspace, but after the last character, it does not accept backspace.</p>
  
  <p>My code is:</p>
  
  <pre><code>$(document).ready(function () {
          $('#txtLoadCode').keydown(function (key) {
              var keycode = (key.which) ? key.which : key.keyCode;
              var code = document.getElementById('&lt;%=txtLoadCode.ClientID%&gt;').value;
              if ((!(keycode==8|| keycode == 46)) &amp;&amp; (keycode &lt; 48 || keycode &gt; 57)) {
                  return false;
              }
              else {
                  //Condition to check textbox contains five numbers or not 
                  if (code.length &lt; 5) {
                      return true;
                  }
                  else {
                      return false;
                  }
              }
          });
      });
  </code></pre>