方法一,超出字元之後就不能再輸入了。<textarea onpropertychange="if(this.value.length>10){this.value=this.value.slice(0,10)}">方法二,超出字元後將會彈出提示。<script language="javascript" type="text/javascript">function chkmaxsms(vobj1,vmax) { var str=vobj1.value; var strlen=str.length; if(strlen>vmax) { alert("字數超過限制"); eval_r(vobj1.value=str.substr(0,vmax)); } } </script><textarea name="textfield" onkeyup="javascript:chkmaxsms(this,"10")">
方法一,超出字元之後就不能再輸入了。<textarea onpropertychange="if(this.value.length>10){this.value=this.value.slice(0,10)}">方法二,超出字元後將會彈出提示。<script language="javascript" type="text/javascript">function chkmaxsms(vobj1,vmax) { var str=vobj1.value; var strlen=str.length; if(strlen>vmax) { alert("字數超過限制"); eval_r(vobj1.value=str.substr(0,vmax)); } } </script><textarea name="textfield" onkeyup="javascript:chkmaxsms(this,"10")">