Skip to content
This repository

A jQuery plugin that displays the remaining characters allowed in a text input.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README
Octocat-spinner-32 jquery.SimpleMaxChars.js
Octocat-spinner-32 jquery.SimpleMaxChars.min.js
README
SimpleMaxChars jQuery plugin v1.0
Author: Josh McCarty
Website: http://joshmccarty.com
Copyright (c)2012 Josh McCarty
License: GPL Version 2
http://www.gnu.org/licenses/gpl-2.0.txt

This plugin adds a message displaying the number of characters remaining in an input or textarea when they have a maxlength set. It's a bit rough around the edges, but I needed a fairly basic solution quickly and most of the existing plugins that offer a similar function were too big, too small, or didn't meet my specific needs. If this looks like it will work for you, feel free to use it!

Highlights:
- Less than 2KB minified.
- Adds a warning class to the message when the character limit has nearly been reached (useful for changing the color of the message text via CSS)
- Uses .prop() and .attr() correctly (.attr() is often used incorrectly for setting/getting DOM properties)
- Multiple instances can be used on the same page
  - Can be used on individual form elements with unique options for each element
  - Can be used on multiple form elements with the same options
- Has built-in options for basic customization
- Remaining character message can be customized via $.fn.SimpleMaxChars.message = function(){ yourCustomFunction });
- Tested with jQuery 1.6.2+, IE7+, Chrome 17, Firefox 8
Something went wrong with that request. Please try again.