How to set the maxLength of a TextArea so that it works across all browsers?
问题 I wrote the below maxLength restriction on the textarea control and it works fine in IE 9.0 but doesn't work with IE 8.0. <textarea name="commentString" rows="7" maxlength="2000">some data </textarea> How can I set the maxLength so that it works across all browsers? would JQuery have any helper method for this? 回答1: $('textarea').keypress(function() { return $(this).val().length < 50; }); 回答2: It will not working below IE9. Use this code it will work for below IE 9 version. only change