<textarea class=textarea id=text1 style="width: 220px; height: 200px" cols=100 onchange="gbcount(this,document.getelementbyid('u
sed'));" onkeyup="gbcount(this,document.getelementbyid('used'));">
</textarea>
已用字数:
<input
disabled maxlength=4 name=used size=5 value=0>
<script type="text/
javascript">
function gbcount(message,used)
{
var lenE = message.value.length;
var lenC = 0;
var CJK = message.value.match(/[^x00-xff]/g);
var enter = message.value.match(/rn/g);
if (CJK != null) lenC += CJK.length;
if (enter != null) lenC -= enter.length;
used.value = lenE + lenC;
}
</script>