Character Limiter: My first Jquery plugin

I was looking for a character limiter for jhoroTEK SMS server reporting panel. Then i found this one in ajaxray’s blog.  Though i liked the code much but writting some extra targeted code seems too much for me. So, i forked a jquery plugin from that one.

Let’s say your textarea class name is ‘test’.

in your HTML head add this :

function() {
$('.test').startCounting({limit: 160});

And here is the plugin file name:  ajaxray_textcounting.js

Original Code was by: AjaxRay ( )
Plugin Written by : Mohammad Amzad Hossain (
Thanks to :

(function($) {

$.fn.startCounting = function(options){

var defaults = {
limit: 30

options = $.extend( defaults, options);

return $(this).each( function(i) {

var elem = $(this);
elem.keyup( function(i) {
var limit = options.limit;
var text = elem.val();
var textlength = text.length;

if( textlength > limit)
{'.counting_class').val( limit + ' / ' + limit);
return false;
{'.counting_class').val( textlength + ' / ' + limit);
return true;


I hope this comes handy… as it comes to me. Dont’ forget to add jquery as it depends on jquery.

Note: Please let me know if you have any pointing, suggestion or bugs :).

Please Download the js file from Download Section or click here . Thanks


One thought on “Character Limiter: My first Jquery plugin

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s