Posted in Javascript onDecember 27, 2013
按字符数控制:
<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 控制输入字符字节数(示例代码)
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@