Fork me on GitHub

jQuery Novelist

Limit user input in textareas or text fields.

The jQuery Novelist Plugin will help to keep users from entering too much content into textareas and text fields.
The plugin gives a visual cue about how much content can still be entered as the user types.

Examples

Configuration

maxCharacters:100

Character limit. If the limit is not defined, the plugin will try get the value from the 'data-max-characters' attribute of the HTML element. Otherwise, the limit is set to the default value (100).

hardLimit:true

If set to true, all characters that go over the limit will be truncated.

backgroundImage:''

Can be used to customize the background image.

backgroundScale:false

Should the background image be scaled to the same dimensions as the textarea/text field?
This feature relies on CSS3 background-size property.

direction:'vertical'

Can be 'vertical' or 'horizontal'.

Callbacks

As you may easily guess by its name onLimitReached callback is fired when a user reaches the character limit.

$('textarea').novelist({
  onLimitReached:function(value) {
    alert(value);
  }
});

The onInput callback is fired on every keystroke.

$('textarea').novelist({
  onInput:function (value, characters, percent, limit) {
    alert('You typed ' + characters + ' out of ' + limit + ' characters (' + percent + '%).');
  }
});

License

Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html

Download

Download the plugin from GitHub.