I was unable to find the solution for my problem (or I just missed it) so I try to get an answer from you.
I have the following html:
<input name="title" type="text" id="title" size="69" maxlength="30" onmouseout="CheckFieldLength(title, 'charcount2', 'remaining2', 30);" onkeydown="CheckFieldLength(title, 'charcount2', 'remaining2', 30);" onkeyup="CheckFieldLength(title, 'charcount2', 'remaining2', 30);"/></td>
I am trying to get the length of the characters of the input field as the following:
<span id="charcount2">0</span> characters entered | <span id="remaining2">140</span> characters remaining
The js file is the following to do the trick:
function CheckFieldLength(fn,wn,rn,mc) {
var len = fn.value.length;
if (len > mc) {
fn.value = fn.value.substring(0,mc);
len = mc;
}
document.getElementById(wn).innerHTML = len;
document.getElementById(rn).innerHTML = mc - len;
}
But, I just keep getting the following error:
uncaught typeerror cannot read property 'length' of undefined
Do you have any idea how to solve the problem?