Forum Moderators: open
I have a following page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>Samix textcounter</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="javascript">
function countlen() {
var arealen = document.form1.area.value.length;
document.form1.counter.value = "length="+arealen;
}
</script>
<FORM id="form1" name=form1>
<textarea name="area" onkeyup="javascript:countlen();"></textarea><br>
<input type="text" name="counter" value="length=0">
</form>
</BODY>
</HTML>
Which works fine, except with netscape and mozilla, it gave me a wrong length! Every enter press increase that value by 2, with IE and Opera, but Mozilla and Netscape 6 increase that value by one!
So one enter length with IE/Opera is 2, but with Netscape/Mozilla counter says it's one, but reality is that, that their length after POST is 2 too!
So, is this some known bug, or what I missed, and how can I fix it? For my system, it's very important to get correct length in that counter with Netscape and Mozilla too.
So following text length with ie is 10, but with netscape length is 7
a
b
c
d
tmpStr = ..form1.area..
c=0
l=len(tmpStr)
outStr = ""
while c < l
c=c+1
midStr = mid(tmpStr, c, 1)
if not midStr = chr(10) and not midStr = chr(13) then outStr = outStr & midStr
wend
arealen = len(outStr)
err.. that's vb (i grabed it from a server script) I just realised your using java, but it should be easy to convert