Control by number of characters:
Copy codeThe Code is as follows:
<Textarea name = "gbContent" style = "width: 500px; height: 200px ;"
Onkeyup = "if (this. value. length> 2000) this. value = this. value. substr )"
Onkeydown = "if (this. value. length> 2000) this. value = this. value. substr )"
Onblur = "if (this. value. length> 2000) this. value = this. value. substr )"
Onpropertychange = "if (this. value. length> 2000) this. value = this. value. substr (0,2000)"> </textarea>
Control by the number of bytes:
Copy codeThe Code is as follows:
<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>