用JavaScript限制textarea输入长度 (For: IE、Firefox ...):

<%--实时统计公司简介的字数,并把字数控制在maxlength个字之内--%> 
 
<script type="text/javascript">
 
//限定文本框的最大输入长度
 
   function isMaxLen(o,info)
 
   {   
 
var Restlen = 0; 
 
var curlen= o.value.length; 
 
var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";
 
if(o.getAttribute && o.value.length>nMaxLen){
 
o.value=o.value.substring(0,nMaxLen)
 
}else{
 
Restlen=nMaxLen - curlen;
 
var rest=document.getElementById(info);
 
document.getElementById(info).innerText=Restlen;
 
}
 
return Restlen;
 
} 
 
</script> 
 <tr>
       <td width="15%"><div align="right"><font color = "ff0000">* </font>公司简介: </div></td>
       <td colspan="3"><textarea rows="6" cols="50" maxlength="300" onKeyDown="return isMaxLen(this,'intro_info');" onBlur="return isMaxLen(this,'intro_info');" onKeyUp="return isMaxLen(this,'intro_info');" name="corp_intro"></textarea>


         最多可输入300个字,还能输入

<input readOnly size="3" id="intro_info" value="300" name="intro" style="BACKGROUND-COLOR: Transparent; border:0px; color:#ff0000"/>个字    </td>
    </tr>