title: Restrict Asp:TextBox to not allow more than 6 character in it
body: <p>I want to restrict the user that he cant enter more than 6 characters in a text box.As a user start entering in the text box and reach to the max limit and try entering 7th character, the text box will not allow him to do so and alert him that max size reached.How i achieve this?</p>
  
  <p>I had added JavaScript function in my code to do so but not getting that on which event i call this function , currently i am calling on on-blur but i m able to type more than 9 character in the text box and after that when i m clicking on a button then i m getting alert message.i want that while typing in the text box itself if max limit reached the user get prompted.My Current code is as follow:-</p>
  
  <pre><code> &lt;asp:TextBox ID="txtVolumeProcessed" runat="server" CssClass="text" MaxLength="999999" onblur="javascript:validate();"  &gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>and the Javascript Code is:-</p>
  
  <pre><code>function validate() {
      if (document.getElementById('&lt;%=txtVolumeProcessed.ClientID%&gt;').value.length &gt; 7) {
          alert("Volume Processed not exceed 999999");
          document.getElementById('&lt;%=txtVolumeProcessed.ClientID%&gt;').select();
          document.getElementById('&lt;%=txtVolumeProcessed.ClientID%&gt;').focus();
          return false;
      }
      else {
          return true;
      }
  }
  </code></pre>