Opened 15 years ago

Closed 15 years ago

#143 closed enhancement (duplicate)

counter to the max char

Reported by: andymnc@… Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:


is there a way to count the number of max chars the user can insert?
can I block the max lenght of the xinha area to, for ex., 500 chars (and how)?

thank you a lot in advice

Change History (6)

comment:1 Changed 15 years ago by andymnc

  • Severity changed from normal to major

comment:2 Changed 15 years ago by niko

  • Priority changed from highest to normal
  • Severity changed from major to enhancement

i think that won't be easy:
what do you count as char?
what do you do with images?
does as h1 count more than a simple p?
how does a <br> count?

comment:3 Changed 15 years ago by andymnc

  • Priority changed from normal to highest

mmm, I have not to count the html chars or tags, but what I see while I'm typing.

This is "I write: CIAO MONDO (THAT IN ENGLISH MEANS &quot;HELLO WORLD&quot;)" in HTML.
I don't need to count these chars but the only the number of chars.
So, in this case, the counter is only 57.

I don't know if I explained well, but it's something like the Ms Word counter of words...

I can explain with another example.
I can do the some thing in this way in php:

$testo = eregi_replace("&#39;", "'", $testo);
$testo = eregi_replace("&nbsp;"," ", $testo);

while($testo != strip_tags($testo))

$testo = strip_tags($testo);


$conta = strlen ($testo);

And the counter is $conta...

comment:4 Changed 15 years ago by niko

yes, something like taht would not be too hard, it would just have to be done with javascript

you could write a custom button or a plugin that does that for you...

comment:5 Changed 15 years ago by andymnc

  • Priority changed from highest to normal

ok, this is the trouble!
I'm trying to solve that problem and do the plugin (to share after!), but I don't understood how to capture the "htmlarea" textarea.length

with a normal textarea I have simply to write something like:
function donaldduck()
var messageField = document.getElementById("id_of_my_textarea_here");
var message = messageField.value;

if (message.length > 500)

messageField.value = message.substring(0, 500);
... do this or do that ...

var tempo = setInterval(donaldduck, 1000);

At present time, I don't really now how to call the "textarea" that xinha create in ram (the one that takes control of the real textarea) from an external xinha plugin, or where put my function in the xinha htmlarea.js (and, again, how to call the "textarea".... var textarea = ..... what?).

thank's again in advice

comment:6 Changed 15 years ago by gogo

  • Resolution set to duplicate
  • Status changed from new to closed

Closing in favor of #223 which seems like it wil include this feature. Discuss there.

Note: See TracTickets for help on using tickets.