Skip to content
Plugin to track the character length of textarea and input values.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit 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);
});
You can’t perform that action at this time.