Setting maximum length of a multiline text box.

Posted by Madhuk under JavaScript category on | Points: 40 | Views : 4370
The Maximum length property of Mutiline text box doesn't work.
This script can be used to set maximum length of the multiline textbox.

<asp:TextBox ID="TextBox1"  onchange="MaxLength(5)" runat="server" TextMode="MultiLine" > </asp:TextBox>

<script language="javascript" type="text/javascript">
function MaxLength(maxLength)
alert("only max " + maxLength + " characters are allowed");
//this limits the textbox with only 5 characters as lenght is given as 5.
text.value = text.value.substring(0,maxLength);

Comments or Responses

Login to post response