实时统计输入字符数
 
None.gif < script >
None.gif    
var $E = document.getElementById;
ExpandedBlockStart.gifContractedBlock.gifString.prototype.lenB
= function () dot.gif {
InBlock.gif    
return this.unHtmlReplace().replace(/\*/g," ").replace(/[^\x00-\xff]/g,"**").length;
ExpandedBlockEnd.gif}

ExpandedBlockStart.gifContractedBlock.gifString.prototype.unHtmlReplace
= function () dot.gif {
InBlock.gif    
var s = (this).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/&quot;/g,"\"");
InBlock.gif      return s.replace(/&#(\d{2});/g,function($0,$1) {return unescape(
"%"+parseInt($1).toString(16));});
InBlock.gif}
InBlock.gif      function onModChange(s, max, o) {      //实时显示输入字数的
InBlock.gif      if(document.readyState !=
"complete") {
InBlock.gif          s = escape(s);
InBlock.gif          setTimeout('onModChange(unescape(
"'+ s+ '"),'+ max+ ',$E("'+ o.id+ '"))', 10);
InBlock.gif          return;
InBlock.gif      }
InBlock.gif      var words=s.lenB();
InBlock.gif      if(words > max)
InBlock.gif          words =
"<font color=red>"+ words+ "</font>";
InBlock.gif      else
InBlock.gif          words =
"<font color=green>"+ words+ "</font>";
InBlock.gif      o.innerHTML =
"已输入"+ words+ "个字符(最多"+ max+ "个字符)";
InBlock.gif}
InBlock.gif</script>

None.gif <!-- S 发表评论 -->
None.gif
< div >
None.gif    
< label >< span > 发表评论: </ span >
None.gif
< textarea name ="content" id ="cmt_content" cols ="50" rows ="3" onpropertychange ="onModChange(this.value, 150, $E('post_status'))" ></ textarea >
None.gif    
</ label >
None.gif    
< div >< em id ="post_status" > 已输入 < font color =green > 0 </ font > 个字符(最多150个字符) </ em ></ div >
None.gif
</ div >
如图所示
5f1ca702d31884054afb51c9.jpg