Hi all,
I’ve successfully implemented a text character counter JS code I picked up on the web, and I was trying to add a spin to it: if the field already has data, tell me how many characters I’ve left based on the current value. Here’s the original code:
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.maxLength-taObj.value.length;
}
I figured all I needed to do was add this…
function ShowMeFirst(visCnt) {
var taObj=event.srcElement;
if (taObj.value.length>0) visCnt.innerText=taObj.value.length;
}
…and then have that code run when the textarea loads. As in: onload=”return ShowMeFirst(MyCounter)”.
Alas, this isn’t working and I don’t know why!! Help, please!!
Me ?