<Script>
Var maxstrlen= 140;
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>
</Head>
<Body>
<Div style = "font-size: 16px">
Control the character input in the input box, calculate the total number of input characters, and display the remaining words. <br> one English character is counted as one character, and one Chinese character is counted as two characters.
</Div>
<Div>
<Textarea onKeyUp = "javascript: checkWord (this );"
OnKeyDown = "javascript: checkWord (this);" name = "content" id = "content"
Style = "overflow-y: scroll"> </textarea>
</Div>
<DIV>
You can also enter <span style = "font-family: Georgia; font-size: 26px ;"
Id = "wordCheck"> 140 </span> characters
</Div>
</Body>