function to restrict text area character

function checkTextLength(obj,restrictLength,truncFlag)
{
if(obj.value.length>restrictLength){
if(truncFlag) obj.disabled = true;
alert(“Text should not be more than ” + restrictLength + ” characters”);
if(truncFlag) obj.disabled = false;
obj.focus();
if(truncFlag) obj.value = obj.value.substring(0,restrictLength);
return false;
}else{
return true;
}
}

Leave your comment