PDA

View Full Version : Real-Time counter in textboxes


DivisionByZero
05-10-2004, 10:37 PM
Want your users to see how many characters they have left in a big textbox? Just add this two step hack and voila!....

Here's a screenshot:

Boofo
05-10-2004, 10:55 PM
Any way to do this for the message box like newreply, newthread and editpost?

DivisionByZero
05-10-2004, 11:16 PM
Yes, just add the script code to the header of the page that will be served, and add the code appropriately for any textarea or textbox.

AN-net
05-11-2004, 02:00 AM
would it still work if we disabled the textbox?

Boofo
05-11-2004, 04:56 AM
Yes, just add the script code to the header of the page that will be served, and add the code appropriately for any textarea or textbox.
Can you please tell us how to add it to the textarea of a message? And will it work accurately with the WYSIWYG editor?

Phalynx
05-11-2004, 08:05 AM
nice one, thanks

gmarik
05-11-2004, 10:59 AM
Great one!

GamerJunk.net
05-11-2004, 01:03 PM
Good job.

DivisionByZero
05-14-2004, 04:00 AM
I do not know if it will work with WYSIWYG, in fact, i doubt it if it's not a standard textarea, and i don't know much about WYSIWYG so it may add the text formatting tags as well. That's a whole new agenda lol

Ok, quick tutorial. I'm assuming you all know how to add the header code in each page served that this functionality will appear on, so we'll move on:

The first thing you need to know is that EACH counter/textarea relationship MUST have it's own unique identifier. This means that each textarea should have a unique "name". Real forms do this anyway so you shouldn't have to worry.

So, to add this functionality to any textarea, you will need to modify the "textarea" tag according to the following example configured to allow 125 characters maximum
<textarea class="bginput" name="MYFORMNAME" cols="28" rows="4" onKeyDown="textCounter(MYFORMNAME,this.form.remLen,125);" onKeyUp="textCounter(MYFORMNAME,this.form.remLen,125);">

And finally, to populate the counter and make it work ONLY with its corresponding textarea, modify it like this:
<input readonly class="bginput" name="remLenMYFORMNAME" size="4" value="125">

That should be it :)

Carter876
05-17-2004, 12:16 PM
Sorry but I haven't understand, if I would to count the number of characters in Newthread and in newpost what I can do?
What code I must to insert and where?

Tnx in advance :)

Regards

filburt1
05-17-2004, 12:36 PM
I released this as a template mod (for vB2, but it will work for vB3 with modifications) at vBT. It includes a progress bar.

Carter876
05-17-2004, 03:38 PM
filburt1 I use Vb 3.01 is you hack compatible, and can you give me the url? :)

Regards

DivisionByZero
01-28-2006, 12:34 PM
3.5.3 update located here: https://vborg.vbsupport.ru/showthread.php?t=97265