In thi article I will explain with an example, how to set MaxLength for Multiline TextBox in ASP.Net using jQuery.
By default the MaxLength property does not work for Multiline TextBox and hence I have created a jQuery Plugin which sets MaxLength for ASP.Net Multiline TextBox and also displays the character count as text is typed.
 
 
HTML Markup
The HTML Markup consists of three ASP.Net TextBoxes for which the Maximum Length validation will be implemented.
There is also an HTML DIV for displaying the Character Count for the second TextBox.
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="300" Height="100"></asp:TextBox>
<br />
<br />
<div id="counter"></div>
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Width="300" Height="100"
    Text="Mudassar Khan"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" Width="300" Height="100"></asp:TextBox>
</form>
 
 
Set MaxLength for Multiline TextBox in ASP.Net using jQuery
The jQuery MaxLength plugin has the following required and optional parameters:
1. MaxLength (required) – Integer value indicating the Maximum character length limit.
2. CharacterCountControl (optional) – By default the plugin will display character count below the TextArea, but user has option to explicitly specify the Character Count Control.
Note: The character count control can only HTML SPAN or DIV.
 
3. DisplayCharacterCount (optional) – Default true. If set to false the Character counting will be disabled.
Inside the jQuery document ready event handler, the MaxLength jQuery plugin is applied to all the three ASP.Net TextBoxes with three different configurations.
First TextBox – Default configuration. Maximum Length validation will be performed and Character count will be displayed.
Second TextBox – Maximum Length validation will be performed and Character Count will be displayed in a HTML DIV.
Third TextBox – Only Maximum Length validation will be performed.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="MaxLength.min.js"></script>
<script type="text/javascript">
    $(function () {
        //Normal Configuration
        $("[id*=TextBox1]").MaxLength({ MaxLength: 10 });
 
        //Specifying the Character Count control explicitly
        $("[id*=TextBox2]").MaxLength(
        {
            MaxLength: 15,
            CharacterCountControl: $('#counter')
        });
 
        //Disable Character Count
        $("[id*=TextBox3]").MaxLength(
        {
            MaxLength: 20,
            DisplayCharacterCount: false
        });
    });
</script>
 
 
Screenshot
Set MaxLength for Multiline TextBox in ASP.Net using jQuery
 
 
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.

 
 
Demo
 
 
Downloads