Link to home
Start Free TrialLog in
Avatar of earwig75

asked on

Limit characters in a text box added with javascript

I am using the following link & script to add a value to a text box. Could someone help me limit this so it can only be run once or limit the text box to not allow more than 7 characaters? Maxlength on the text box doesn't work. If I click the link twice it will enter the value twice right next to eachother.

<a href="##" value="happy" onclick="addme(this.value)">Add it</a>

    function addme(iii) {
    var txt=document.getElementById("theTxtBox").value;
    txt=txt + iii;

Open in new window

Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial