JQuery Maxchars Plugin

By febin JS Dec 01, 2010
JQuery Maxchars Plugin

Had a glance on JQuery's new feature, thought of sharing this with you - "Maxchar" plugin. I found this plugin very useful since we are using similar kind of sinareos in our projects, I think this might be helpful for you guys also.

As there are many senarios where we have to restrict characters in our UI controls, so usually we go for a UI property maxLength or some custom jQuery methods for doing like that as we had done in our Projects Mylo & others. But now JQuery had released Maxchar plugin so that its very simple to use.

This plugin is freely available in net:-
How to use this plugin is elaborated by some examples below :-

Suppose in our page we have a textArea [id="description"], for that we have to limit the character upto 400.


  The basic syantax of this is


  We can also define similar options by using this single code ie for example

maxchars: 400,
showExtraChars: true,
messageHolder: $('div.messagebox') });


maxchars:- Its the maximum number of characters that can be given inside a particular control , if this is blank it will take the html maxlength property value by default.

showExtraChars:- Its a boolean value , if set to true we can type extra characters inside the control. but if false it will automatically delete the extra characters what we have entered into the control.

messageHolder:- It will hold the control where we can show the remaining characters.