Created
February 12, 2013 12:00
-
-
Save gauravsaini23/4761870 to your computer and use it in GitHub Desktop.
apply maxlength attribute to textarea (for ie)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('textarea[maxlength]').live('keyup blur', function() { | |
// Store the maxlength and value of the field. | |
var maxlength = $(this).attr('maxlength'); | |
var val = $(this).val(); | |
// Trim the field if it has content over the maxlength. | |
if (val.length > maxlength) { | |
$(this).val(val.slice(0, maxlength)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment