TextArea input box limit words (perfect compatibility)

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.