To solve that problem, I created a modified version that seems to be working so far:
function textCounter(field,cntfield,maxlimit) {
var extra = 0;
if (navigator.appName=="Netscape" &&
parseInt(navigator.appVersion)>=5) {
var index = field.value.indexOf('\n');
while(index != -1) {
extra += 1;
index = field.value.indexOf('\n',index+1);
}
}
if (field.value.length + extra > maxlimit)
field.value = field.value.substring(0, maxlimit-extra);
else
cntfield.value = maxlimit - field.value.length - extra;
}
In case of Firefox (and Netscape, for that matter), it counts the breaklines, adding or subtracting this amount when checking the number of characters.
If you find some problem here or know a better version available on the internet, please let me know. I searched, but couldn't find a version that overcomes this Firefox behavior.
1 comments:
Thanks so much for your script. i've had the same problem, and your script really helps me.
thanks again
the justin
Post a Comment