Hello all!
I’m using this bit of JS code I downloaded to count how many characters are in a text field:
<script language = “Javascript”>
/**
* DHTML textbox character counter (IE4+) script. Courtesy of SmartWebby.com (
function taLimit() {
var taObj=event.srcElement;
if (taObj.value.length==taObj.maxLength*1) return false;
}
function taCount(visCnt) {
var taObj=event.srcElement;
if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength
if (visCnt) visCnt.innerText=taObj.value.length;
}
</script>
I have this tag for the field itself:
<textarea onkeypress=”return taLimit()” onkeyup=”return taCount(myCounter)” maxLength=”75″ wrap=physical rows=”2″ name=”AgentTitle” cols=”40″>
And I also have a span bit near it that counts the characters used:
<span id=myCounter>0</span> of 75 characters used
With my limited knowledge of JavaScript I cannot figure out how to make that bit of “SPAN” tell the user the number of characters in the field, if it already has stuff in it. Can someone help me out?
Thanks a bunch!!
Natalia