Code:
 <asp:TextBox ID="TextBox1" runat="server" onKeyPress='return maxLength(this,"30");'></asp:TextBox>
Code:
function maxLength(field,maxChars)
 {
 alert('onKeyPress');
       if(field.value.length >= maxChars) {
          event.returnValue=false; 
          alert("more than " +maxChars + " chars");
          return false;
       }

 }
When I Press any Character , maxLength function is not called,WHy SO?