Dodo's Text Counter

Demo

Creating a counter display

chars left

Code: (expand/collapse)

Using a display that already exists


characters remaining

Code: (expand/collapse)

Creating a custom element

chars left

Code: (expand/collapse)

Applying plugin to multiple inputs with the same class

chars left

chars left

chars left

Code: (expand/collapse)

Documentation

Basic Usage

Include jQuery and this plugin js in your HTML header

<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" src="js/jquery.dodosTextCounter-0.1.pack.js"></script>

counterDisplayElement (string)

Tag for the counter display. Default to "span".

counterDisplayClass (string)

CSS class for the counter display. Default to "dodosTextCounterDisplay".

counterDisplayElement & counterDisplayClass

The plugin will use existing element when it could find it in the DOM. Otherwise, the plugin will create the element.

addLineBreak (boolean)

Whether to add <br /> after the input element before the counter display. Default to true.

Download