I tend to use a variation on this script
<script language="javascript" type="text/javascript">
<!--
function setMaxLength() {
var x = document.forms[0].getElementsByTagName('textarea');
for (var i=0;i<x.length;i++) {
if (x[i]) {
x[i].onkeyup = x[i].onchange = checkMaxLength;
x[i].onkeyup();
}
}
}
function checkMaxLength() {
var maxLength = 10;
var currentLength = this.value.length;
if (currentLength > maxLength)
this.value = this.value.substring(0, maxLength);
}
</script>
Behind the scenes, ASP.NET converts a multi-line textbox into a text area, so you would run this script once the page has loaded (e.g.
<body onload="javascript:setMaxLength();">).
It has the advantage that it takes into account the case where somebody tries to paste text that would break your upper limit.