<textarea maxlength="50">This textarea has a character limit of 50.</textarea>
<script>
var textareas = document.getElementsByTagName('textarea');
for (var i = textareas.length; i--;) {
if (textareas[i].getAttribute('maxlength') && !textareas[i].maxlength) {
var max = textareas[i].getAttribute('maxlength');
textareas[i].onkeypress = function(event) {
var k = event ? event.which : window.event.keyCode;
if(this.value.length >= max) if(k>46 && k<112 || k>123) return false;
}
}
}
</script>