PDA

View Full Version : text field counter


Tussi
05-25-2004, 03:42 PM
Hi, I just wondered how you make these, counter things on text fields.

I have a form, with a text input that has a maximum of 90 letters, or something like that.

How can you make a small text thing, that displays how many letters you have left when your writing?

agent002
05-25-2004, 04:15 PM
Hi Tussi,
add this attribute to the <input> or <textarea>, whichever it is:
onkeypress="document.getElementById('counterForMe').value = (this.maxLength - this.value.length);"
Then, create another input to display the counter:
<input id="counterForMe" readonly="readonly" size="3">
:)

Tussi
05-25-2004, 04:21 PM
cool! i've always wondered how to do that, thanks a lot! :thumbup: