Using the simple script below, multi-line textboxes will prevent a user from exceeding the MaxLength property.
* Note - using System.Text;
StringBuilder funcStr = new StringBuilder();
funcStr.Append("function isMaxLength(txtBox) {");
funcStr.Append("if(txtBox){");
funcStr.AppendFormat("return(txtBox.value.length <= {0});", aTextBox.MaxLength);
funcStr.Append("}}");
aTextBox.Attributes.Add("onkeypress", "return isMaxLength(this);");
ClientScript.RegisterClientScriptBlock(
this.GetType(),
"txtLength",
funcStr.ToString() , true);
1 comment:
does not allow to edit once max characters are inserted.
Post a Comment