Вот примерчик набросал:
<html>
<head>
<style type="text/css">
.border-black {border: 1px solid black}
.border-red {border: 1px solid red}
</style>
<script type="text/javascript"><!--
var maxLen = 0;
function checkLength (object, len)
{
object.className = ( object.value.length > len ) ? "border-red" : "border-black";
}
function setMaxLength (object, len)
{
maxLen = len;
with ( object )
{
maxLength = maxLen;
onkeyup = function (event) {checkLength (this, maxLen)};
onkeydown = function (event) {checkLength (this, maxLen)};
onchange = function () {checkLength (this, maxLen)};
className = "border-black";
}
}
function validate (form)
{
if ( form.text.value.length > maxLen )
{
alert ("Длинна текста больше допустимой");
form.text.focus();
return false;
}
return true;
}
//--></script>
</head>
<body onload="setMaxLength (document.getElementById ('text'), 10)">
<form onsubmit="return validate (this)">
<textarea cols="60" rows="12" id="text" name="text"></textarea><br>
<input type="submit" value=" Отправить ">
</form>
</body>
</html>