Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created August 20, 2012 15:51
Show Gist options
  • Select an option

  • Save cam-gists/3405317 to your computer and use it in GitHub Desktop.

Select an option

Save cam-gists/3405317 to your computer and use it in GitHub Desktop.
JQuery: Charecter Counter
// controls character input/counter
$('textarea#body').keyup(function() {
var charLength = $(this).val().length;
// Displays count
$('span#charCount').html(charLength + ' of 250 characters used');
// Alerts when 250 characters is reached
if($(this).val().length > 250)
$('span#charCount').html('<strong>You may only have up to 250 characters.</strong>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment