Forum closed. New forum available at

Character counting and limiting

Support forum for WYMeditor.

Character counting and limiting

Postby Clement on Wed Aug 29, 2007 2:33 pm

First of all, congrats for your work. WYMeditor is very easy to integrate and to customize.

I would like to use WYMeditors in my webapp but I have to find a way to count and limit the number of characters that the user can type ... sort of client-side validation, to avoid problem when insert data into database.
(It would be great to be able to configure it to count the number of characters of the formatted text (with html formatting) OR the unformatted one)

I used to have some javascript functions that were doing it well for "normal" text-area but doesn't work anymore with WYMeditor.

Did someone already tried to do it ? Does it seems easy to develop or not ? Could it be done in a plugin ?

Posts: 2
Joined: Wed Aug 29, 2007 2:16 pm

Postby jfh on Wed Aug 29, 2007 8:16 pm


Code: Select all
jQuery(function() {

        postInit: function(wym){

            jQuery(wym._doc).bind('keydown', function(evt) {
                if(jQuery(wym._doc.body).html().length > 1000 //limit to 1000 chars
                  && evt.keyCode != 8  && evt.keyCode != 46 //backspace and delete
                ) return(false);

The user will still be able to insert images, tables...
You should e.g. hide the buttons as long as the limit has been reached.
User avatar
Site Admin
Posts: 370
Joined: Sat Sep 23, 2006 8:43 pm
Location: Belgium

Postby Clement on Mon Sep 03, 2007 8:04 am

OK thank you for the tip. I'll try to do it later (not enought time those days). I'll post a feed back as soon as it will be done.
Posts: 2
Joined: Wed Aug 29, 2007 2:16 pm

Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests