textarea Input box limit words (perfect compatibility)
url:http://www.thylx.net/newsdetail.aspx?id=37
2014-03-31 17:17:34
In the Input tab, you only need to set the maxlength= "* *" can, but in the textarea tag, IE9 and IE9 the following browsers are not supported, IE10, IE11 support, the estimated subsequent version should be supported.
Now, how to make most IE versions support TEXTAREA tags to limit the word count.
<textarea id= "Tacontent" rows= "3" maxlength= "Onchange=" (0) "This.value=this.value.substring" "This.value=this.value.substring (0)" onkeyup= "this.value=this.value.substring (0)" ></textarea>
This way you can.
Remark: OnChange, onkeydown, onkeyup three are indispensable.
If omitted onchange, when you use the responsible function, has been pressing the CTRL not to loosen, the mouse clicks the other place (the focus moves out textarea), does not automatically cancel the excess part;
If you omit onkeydown, there will be a lot of characters suddenly disappear;
If you omit onkeyup, you would expect 20 to be 21, and the last character will be the last to be knocked in.
Maxlength also can not be omitted, plus Maxlength when touching the IE10 and above version, it is possible to achieve the perfect limit of the number of input box word function. Don't want another low version of IE browser can also appear after a letter disappeared.
This document is provided by eight network THYLX, reproduced please indicate the source: http://www.thylx.net/newsdetail.aspx?id=37