<head> <script language=javascript> function textLimitCheck(thisArea maxLength) { if (thisAreavaluelength > maxLength) { alert(maxLength + 个字限制 \r超出的将自动去除); thisAreavalue = thisAreavaluesubstring( maxLength);thisAreafocus(); } messageCountinnerText = thisAreavaluelength;/*回写span的值当前填写文字的数量*/ } </script> </head> 调用方法: <span >限 个字符 已输入 </span><font color=#cc><span id=messageCount> </span></font><span > 个字</span> <textarea id=tbtext name=tbtext onkeyup=textLimitCheck(this) ></textarea> |