We help IT Professionals succeed at work.

Applying a character counter to a Textbox

rito1
rito1 asked
on
2,171 Views
Last Modified: 2013-12-03
Hi All

I have found several javascript textbox counters that count down the remaining character a user has left, but I am struggling to figure out how to apply them to textbox control. The reason being is that a lot of them are demonstrated on HTML textarea elements and use the events onkeypress and onkeyup.

Does anyone know how I could configure a textbox control to use a counter script or is there an alternative method that anyone can suggest that is more suited to the Textbox control.

Many thanks

Rit
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Applications and Integrations Consultan
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Excellent, thanks you both for your help.

Timcottee, the only tweak I had to do was the following...

With MyTextBox
    .Attributes.Add("onkeypress","return taLimit();")
    .Attributes.Add("onkeyup","return taCount("& MyLabel.ClientID & ");") ' Add the ladel's clientid here***************
    .Attributes.Add("maxLength", "1000") ' add the maxlength as it didn't seem to like the textbox's version of this.***********
End With

Kind Regards

Rit
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.