TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
JQuery Maxchars Plugin
febin JS
May 25, 2012
6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
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:-
http://www.unleashed-technologies.com/projects/maxchars/jquery.maxchars.0.0.zip
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.
$('#discription').maxchars(400);
The basic syantax of this is
$('#elementID').maxchars(options);
We can also define similar options by using this single code ie for example
$('#discription').maxchars({
maxchars: 400,
showExtraChars: true,
messageHolder: $('div.messagebox') });
Here
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.
JQuery Maxchars Plugin
Next Recommended Reading
jQuery migrate to new version plugin