<html>
<head>
<title>实时显示输入
文本框字数与限制输入数-www.jb200.com</title>
</head>
<body>
<script language=
javascript>
function gbcount(message,total,u
sed,remain)
{
var max;
max = total.value;
if (message.value.length > max) {
message.value = message.value.substring(0,max);
used.value = max;
remain.value = 0;
alert("内容不允许超过30个字!");
}
else {
used.value = message.value.length;
remain.value = max - used.value;
}
}
</script>
<form>
<textarea name="quotation" onmousedown="this.className='cdown'" onmouseover="this.className='cup'" onmouseout="this.className='cnone'" onkeydown=gbcount(this.form.quotation,this.form.total,this.form.used,this.form.remain); onkeyup=gbcount(this.form.quotation,this.form.total,this.form.used,this.form.remain); cols="80" rows="8" wrap="VIRTUAL" id="quotation">
</textarea> <br>
最多字数:<INPUT class=cnone
disabled maxLength=4 name=total size=3 value=30> <!--value设置最多字数的初始值 -->
已用字数:<INPUT class=cnone disabled maxLength=4 name=used size=3 value=0>
可用字数:<INPUT class=cnone disabled maxLength=4 name=remain size=3 value=30><!--value设置可用字数的初始值 -->
</form>
</body>
</html>