相思资源网 Design By www.200059.com

按字符数控制:
复制代码 代码如下:
<textarea name="gbContent"  style="width: 500px; height: 200px;"
             onkeyup="if(this.value.length>2000) this.value=this.value.substr(0,2000)"
             onkeydown="if(this.value.length>2000) this.value=this.value.substr(0,2000)"
             onblur="if(this.value.length>2000) this.value=this.value.substr(0,2000)"
             onpropertychange= "if(this.value.length>2000) this.value=this.value.substr(0,2000)"></textarea>

按字节数控制:
复制代码 代码如下:
<textarea cols="50" id="description" name="userModel.description" rows="5"
      onkeydown="key1=this.value;value1 = key1.replace(/[\u4e00-\u9fa5]/g,' ');if(value1.length>500) this.value=this.value.substr(0,500)"
      onkeyup="key1=this.value;value1 = key1.replace(/[\u4e00-\u9fa5]/g,' ');if(value1.length>500) this.value=this.value.substr(0,500)"
      onblur="key1=this.value;value1 = key1.replace(/[\u4e00-\u9fa5]/g,' ');if(value1.length>500) this.value=this.value.substr(0,500)" 
      onchange="key1=this.value;value1 = key1.replace(/[\u4e00-\u9fa5]/g,' ');if(value1.length>500) this.value=this.value.substr(0,500)"></textarea>

标签:
textarea,字符数

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“textarea 控制输入字符字节数(示例代码)”

暂无textarea 控制输入字符字节数(示例代码)的评论...