PDA

View Full Version : Characters counter


Lionel
01-10-2002, 06:21 AM
Well, I do not pretend this to be a hack, nor do I know if someone else has done it. I found it somewhere and thought that it could be useful to some.

In newthread template find:

<textarea name="message" rows="20" cols="$textareacols" wrap="virtual" tabindex="2">$message</textarea>

and replace with:

<textarea name="message" rows="20" cols="$textareacols" wrap="virtual" tabindex="2" onkeypress="compter(this.form)">$message</textarea><input type="text" name="nbcar" size=3>

then Set the var max= to your config in the script below and place the javascript anywhere between <body> and </body>

<SCRIPT LANGUAGE="JavaScript">
var max=2000;
function compter(f) {
var txt=f.message.value;
var nb=txt.length;
if (nb>=0) {
nb=nb+1;
}
if (nb>max) {
alert("Can't have more than "+max+" characters in your post");
f.message.value=txt.substring(0,max);
nb=max;
}
f.nbcar.value=nb;
}

function timer() {
compter(document.forms["form1"]);
setTimeout("timer()",100);
}

</SCRIPT>

Use it for the other templates too.

Lionel
01-10-2002, 06:22 AM
here is what it looks like

Lionel
01-10-2002, 06:51 AM
After I posted, I found this (https://vborg.vbsupport.ru/showthread.php?s=&threadid=33909) which I think is much nicer.

Nam
01-10-2002, 03:41 PM
Don't worry, I like your style better, thanks :).

Shenlong
01-10-2002, 11:29 PM
I agree, your style is much better and easier to configure, thanks so mcuh for this hack! A+! Make some more!

Shenlong
01-10-2002, 11:30 PM
By the way, heres a message from a user:

Teleblaze,
Thanks for installing that message hack, sometimes I was posting a long tutorial and didn't know when my characters would run out, now I know perfectly and such an easy location to see! Whoever made this, thank them!

Sincerely,
XX_Reaper_XX

^Look, a happy user^

Thanks again!

Shenlong
01-10-2002, 11:43 PM
Hey, how do I make the box appear, the script is easy for the visitors to see but the box would be nicer, how do I add that, the only thing it says is:

[check character length]

Lionel
01-11-2002, 01:59 AM
All there is to it is to adjust your html accordingly. For example if you want to make the input bigger just say so in the input size.

BTW, I unistalled and placed a modified html hack of the other one. It looks nicer and I will encourage people to use it.

Jawelin
01-11-2002, 06:58 AM
As I can see, the other's hack is still under revisioning...
Meanwhile, I installed yours ! ;)
Thanks a lot.

bokhalifa
01-11-2002, 09:42 AM
nice job :)
Works greathttps://vborg.vbsupport.ru/external/2011/01/19.gif

Erwin
01-13-2002, 06:20 PM
Can you integrate this with the updated Javascript smilie hack? That one inserts changes into the textarea too.

Lionel
01-19-2002, 05:58 AM
Originally posted by Erwin Loh
Can you integrate this with the updated Javascript smilie hack? That one inserts changes into the textarea too.

sorry I am not familiar with that hack