How To Restrict Input In MultiLine TextBoxes

MultiLine TextBoxes are rendered as a TEXTAREA to the client. There is no maxlength property on a TEXTAREA.

When you set the the TextMode to MultiLine in an ASP.NET TextBox the MaxLength property is ignored. To get around this obstacle use JavaScript:

/*
function CharCountRestriction

Param: text (text to evaluate)
Param: long (length of text to restrict upon)

Restricts input of characters into multiline textboxes

Implementation: Add the following to your Textbox: onKeyUp="CharCountRestriction(this,200)" onChange="CharCountRestriction(this,200)" 

*/
<script language="javascript">
        function CharCountRestriction(text, long) {
            var maxlength = new Number(long);
            if (text.value.length > maxlength) {
                text.value = text.value.substring(0, maxlength);
                alert(" Only " + long + " chars");
            }
        }
 <asp:TextBox runat="server" ID="tbJobName" TextMode="MultiLine"
            onKeyUp="CharCountRestriction(this,200)" onChange="CharCountRestriction(this,200)"></asp:TextBox>