Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Plugin to track the character length of textarea and input values.
branch: master

This branch is even with craigmccoy:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
.gitignore
README.md
jquery.charcount.js
jquery.charcount.min.js

README.md

jquery.charcount.js is a jQuery plugin for counting character limits of text form elements.

  • configurable maximum length
  • configurable user feedback (by position or custom callback)

Live Demonstration

Click here to view a live demo.

Quick Documentation

$(selector).charcount(options);

options: A set of key/value pairs that configure settings for the plugin. All options are optional.

  • maxLength: (type: Integer, default: 250) Number of characters to limit the field to.
  • position: (type: String, default: "before") Where to position the plugin feedback. Available options are "before", "after", and "none".
  • preventOverage: (type: Boolean, default: true) If true, characters exceeding the set maxLength will be trimmed.
  • classPrefix: (type: String, default: "charcount") This string is prefixed to all classes used by the plugin.

Events

update: Triggered after every update to an element's character count. The current character length and remaining character length (maxLength - current character length) are provided as additional arguments.

charcount: Triggering this event will cause the plugin to update the character count for the element.

Usage Example

$('#text').charcount({
    maxLength: 50,
    position: 'after'
});

//using event to provide feedback
$('#text').charcount({
    position: 'none'
}).bind('charcount', function(evt, length, remaining)) { 
    console.log('length: ' + length, 'remaining: ' + remaining);
});
Something went wrong with that request. Please try again.