<div class="form"> <br><div class="con"> <br><ul> <br><li>剩余字数的限制</li> <br><li><textarea cols="40" rows="8" id="text1"></textarea></li> <br><li>剩余字符:<span id="textleft"></span> </li> <br> </ul> <br> </div> <br> </div> <br><br><script language="javascript"> <BR>var otext = document.getElementById("text1"); <BR>var otextleft = document.getElementById("textleft"); <BR>var re = /[^\x00-\xff]/g; <BR>var maxLength = 40; <BR>window.onload = function(){ <BR>if(document.all) <BR>otext.onpropertychange = textleft; <BR>else <BR>otext.onkeypress = textleft; <BR>} <BR>function textleft() <BR>{ <BR>var str = otext.value; <BR>str = str.replace(re,"xx");//中文字符当2个字符处理 如果不用的话主是掉本行 <BR>otextleft.innerHTML = maxLength - str.length; <BR>} <BR></script>