<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Show input remaining words </title>
<script>
var maxstrlen=160;
function Q (s) {return document.getElementById (s);}
function Checkword (c) {
Len=maxstrlen;
var str = c.value;
Mylen=getstrleng (str);
var wck=q ("Wordcheck");
if (mylen>len*2) {
C.value=str.substring (0,i+1);
}
else{
wck.innerhtml = Math.floor ((len*2-mylen)/2);
}
}
function Getstrleng (str) {
Mylen = 0;
i=0;
for (;(i<str.length) && (mylen<=maxstrlen*2); i++) {
if (Str.charcodeat (i) >0&&str.charcodeat (i) <128)
mylen++;
Else
mylen+=2;
}
return Mylen;
}
</script>
<body>
<div style= "font-size:16px" >
Control input box character input, calculate the total number of input characters, display the remaining words;<br>
An English character is counted as a char, and a Chinese character is counted as two characters.
</div>
<div>
<textarea onkeyup= "Javascript:checkword (This)," onmousedown= "Javascript:checkword (this);" Name= "Content" style= "Overflow-y:scroll" ></textarea>
</div>
<DIV>
You can also enter <span style= "Font-family:georgia; font-size:26px; "id=" Wordcheck ">160</span> characters </div>
</body>