<html>
<head>
<title>JS限制Textarea文本域字符个数</title>
<meta httpequiv="ContentType" content="text/html; charset=gb" />
<SCRIPT LANGUAGE="JavaScript">
<!//
function textCounter(field countfield maxlimit) {
// 函数个参数表单名字表单域元素名限制字符
if (fieldvaluelength > maxlimit)
//如果元素区字符数大于最大字符数按照最大字符数截断
fieldvalue = fieldvaluesubstring( maxlimit);
else
//在记数区文本框内显示剩余的字符数
countfieldvalue = maxlimit fieldvaluelength;
}
//>
</SCRIPT>
</head>
<body>
<form name=myform action="">
<textarea name="message" cols="" rows="" onKeyDown="textCounter(messageremLen);" onKeyUp="textCounter(messageremLen);"></textarea>
您还可以输入:<input name="remLen" type="text" value="" size="" readonly="readonly">个字符
</form>
</body>
</html>