Skip to content

TwitLimit – jQuery Character Limiter

What is it?
How to Use
Options
Demonstrations
Download Code

What is it?:

TwitLimit is a Twitter-esque character limit jQuery plug-in. Licensed under the MIT & GPL licenses.

How to Use:

1. Include the jQuery library from Google Code and then include the TwitLimit javascript file.
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js”></script>
<script type=”text/javascript” src=”/twitlimit/twitlimit-0.2.0.compressed.js”></script>
2. Put a “counter” div and a textarea in your HTML body.
<div id=”limit”></div>
<textarea id=”limitThis”></textarea>
3. Make use of the plug-in using a selector.
<script type=”text/javascript”>
$(document).ready(function() {
$(‘#limitThis’).twitLimit({});
});
</script>

Boom! There ya go!

Options:

Key Default Value Description
limit 140 Default limit, if no limit set upon selector. (In honor of Twitter <3)
message %1 Characters Remaining. Keep %1 intact when defining custom message. (%1 is replaced by number of characters left.)
counterElem #limit ID or Class of element where you want the message to display.
allowNegative false Whether to allow the count to go negative or not.
dangerMode true Will change the number of characters left “%1” with the colors defined in dangerColors.
dangerBold true Will make the number of characters left “%1” bold.
dangerColors {

dark:550505‘,

medium:980808‘,

bright:e90909
}

Colors for dangerMode.
onNegative null Called when character limit is less than zero.
onPositive null Called for when character limit is greater than or equal to zero.

One Comment

  1. Amiable brief and this mail helped me alot in my college assignement. Say thank you you as your information.

Leave a Reply

Your email address will not be published. Required fields are marked *