MaxLength in TextBox control in ASP.Net
When I was use TextBOx with TextMode "MultiLine" and MaxLength "10".I can enter more than 10 characters. SO I use Java Script for that and it solve my problem.
JavaScript like this :
< language="javascript">
function limitCharsLength(Object, MaxLen)
{
return (Object.value.length <= MaxLen-1);
}
< /script >
and TextBox like this :
< asp:TextBox ID="TextBox1" runat="server" Height="173px" TextMode="MultiLine"
Width="369px" onkeypress="javascript: return limitCharsLength(this,5);"
onblur="javascript: limitCharsLength(this, 5)"
onchange="javascript : return limitCharsLength(this, 5)" >< /asp:TextBox >
No comments:
Post a Comment