The following code works great for locking the keyboard in IE6 and IE8 when a textarea reaches a certain length. Of course, it doesn't work on other browsers, and I can't figure out a way to turn it into a jQuery function that will work cross-browser. Is it possible to get the same behavior in FireFox and Webkit browsers?
function checkLength(fld, maxLength){
if(fld.value.length > maxLength-1){
event.returnValue = false;
}
}
<p><textarea name="third" id="third" onkeypress="checkLength(this, 10);">hello</textarea></p>