Click to See Complete Forum and Search --> : MaxLength property of TextBox


rahulvasanth
November 10th, 2005, 10:39 PM
Hi

I m new to asp.net

I have a TextBox whose TextMode is set to MultiLine. I have also set the maxLength property of the TextBox as 500. But I m able to enter more than 500 characters.

But a maxlength propery of textbox with SingeLine mode is working fine.

Am I missing something over here ?

Thanking in advance

HanneSThEGreaT
November 11th, 2005, 03:44 AM
Hello again Rahul!
You'll have to use JavaScript again for that :rolleyes:
Try:
<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">
<!--
function textCounter(field, maxlimit) {
if (field.value.length > maxlimit)
{
field.value = field.value.substring(0, maxlimit);
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="texBox" id="A" onKeyDown="textCounter(this,500);" onKeyUp="textCounter(this,500);">
</BODY>
<HTML>
The bolded letters are the length!

Hope this helps!

rahulvasanth
November 14th, 2005, 01:29 AM
It Works....!!!!!

Thanks, Once again

HanneSThEGreaT
November 14th, 2005, 01:45 AM
No problem buddy! :)