I took reference from here Maxlength Validation in HTML TextArea using jQuery and extended it
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
//Restrict text while typing
$("textarea[class*=max]").live("keypress", function () {
var maxLength = $(this).attr("class").replace("max", "");
$("#counter").html(maxLength - $(this).val().length + " characters left.");
return $(this).val().length <= maxLength - 1;
});
$(document).ready(function () {
$("#counter").html("0 characters left.");
$("textarea[class*=max]").bind('paste', function () {
var textarea = $(this);
var maxLength = textarea.attr("class").replace("max", "");
setTimeout(function () {
textarea.val(textarea.val().substring(0, maxLength));
}, 100);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id = "counter" style = "text-align:right;width:200px"></div>
<asp:TextBox ID="TextBox1" runat="server" TextMode = "MultiLine" Width = "200" CssClass = "max150"></asp:TextBox>
</form>
</body>
</html>