htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Add-Ons:
maxlength in HTMLArea 3 RC1


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


gi_gio
New User

Dec 6, 2004, 7:53 AM

Post #1 of 1 (5142 views)
Shortcut
maxlength in HTMLArea 3 RC1 Can't Post

Hi, I've just upgraded to HTMLArea 3 RC1, it's simply great!
However, in version 2.0, I modified the function:
function editor_event(objname,runDelay)
so I could delete any char (typed or pasted) exceeding a fixed "maxlength".


Code
  var contents = editor_getHTML(objname); 

// Added code
var fullcontents = editor_getHTML(objname);
var full = '';
if (config.maxlength) {
contents = contents.replace(/<[^>]+>/g, ''); //Don't count HTML tags
contents = contents.replace(/&[^;]+;/g, ' '); //Count &chr; as one keystroke
if (contents.length >= config.maxlength) { var full = 1; }
document.all[objname+'_cnt'].value = config.maxlength-contents.length;
if (full == 1) {
while (document.all[objname+'_cnt'].value <= 0) {
fullcontents=fullcontents.substring(0,fullcontents.length-1);
contents = fullcontents.replace(/<[^>]+>/g, ''); //Don't count HTML tags
contents = contents.replace(/&[^;]+;/g, ' '); //Count &chr; as one keystroke
document.all[objname+'_cnt'].value = config.maxlength-contents.length;
}
editor_setHTML(objname,fullcontents);
}
}



This also allowed me to display to the user how many chars are still available.

Now, I know that this code is not much efficent, but I wonder: how can I do such a thing in the ver 3.0?

Thanks in advance!

gi_gio

 
 
 


Search for (options)