Here is my jQuery based solution. Works well in IE9, a little wonky in IE8.
// textarea event handler to add support for maxlength attribute
$(document).on('input keyup', 'textarea[maxlength]', function(e) {
// maxlength attribute does not in IE prior to IE10
// http://stackoverflow.com/q/4717168/740639
var $this = $(this);
var maxlength = $this.attr('maxlength');
if (!!maxlength) {
var text = $this.val();
if (text.length > maxlength) {
// truncate excess text (in the case of a paste)
$this.val(text.substring(0,maxlength));
e.preventDefault();
}
}
});
http://jsfiddle.net/hjPPn/
link for IE8: http://jsfiddle.net/hjPPn/show
Native Browser Support
Also, in case you're wondering which browsers do support maxlength
: https://caniuse.com/#search=maxlength