Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created July 24, 2012 04:41
Show Gist options
  • Select an option

  • Save ctrl-freak/3168078 to your computer and use it in GitHub Desktop.

Select an option

Save ctrl-freak/3168078 to your computer and use it in GitHub Desktop.
Working HTML maxlength on <textarea> Using jQuery
$(document).ready(function(e){
$('textarea[maxlength]').keydown(function(){
if ($(this).val().length > $(this).attr('maxlength')) {
e.preventDefault();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment