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>
<script>
function addme(iii) {
var txt=document.getElementById("theTxtBox").value;
txt=txt + iii;
document.getElementById("theTxtBox").value=txt;
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.