Skip to content

Instantly share code, notes, and snippets.

@kongondo
Forked from somatonic/TextAreaCounter.js
Created June 7, 2013 09:24
Show Gist options
  • Save kongondo/5728118 to your computer and use it in GitHub Desktop.
Save kongondo/5728118 to your computer and use it in GitHub Desktop.
TextAreaCounter JScript for TextAreaCounter concept module
(function($){
$(function(){
$('textarea[data-maxlength]').each(function(){
$(this).bind("keyup change", function(){
var count = $(this).attr('data-maxlength') - $(this).val().replace(/\r?\n/g, '\r\n').length;
$(this).parent().find("span.counter span").text(count);
});
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment