Textarea element and textarea object

Source: Internet
Author: User

The project uses the HTML control of multi-line text such as textarea multiple times. You need to master the following features to use the control on the Web Front-end.

1. Cols -- number of columns in multiple input fields
2. Rows -- number of rows in multiple input fields

Note: Cols: vertical column. If no style sheet is set, it indicates the number of bytes that a row can accommodate. For example, cols = 80 indicates that a row can contain up to 40 Chinese characters. The same applies to rows.

3. The wrap attribute defines the display mode when the input content is greater than the text field. The optional values are as follows:

    • The default value is automatic text line feed. When the input content exceeds the right boundary of the text field, it is automatically transferred to the next line. line breaks are not generated when the data is submitted for processing;
    • Off to avoid text wrapping. When the input content exceeds the right boundary of the text field, the text will scroll left. You must use return to move the insertion point to the next line;
    • Virtual, allows text to wrap automatically. When the input content exceeds the right boundary of the text field, it is automatically transferred to the next line, and there is no line break where the data is automatically wrapped when it is submitted;
    • Physical allows text wrapping. line breaks are also submitted when data is submitted for processing.

4. Style = "overflow: hidden" (including overflow-X: hidden and overflow-y)

HideTextarea(Horizontal and vertical)

6. textarea does not have the value attribute (innerhtml)

< Textarea Name = "Mutlietext" Cols = "50" Rows = "5" Disabled > Charles </ Textarea >

7. display the input length of the multi-line text box.

Setting the maximum length with the maxlength attribute does not work. It must be set using a script.

Function Setmaxlength (control, maxlength)
Control. attachevent ( " Onkeypress " , Function (){ If (TRIM (control. Value). Length > = Maxlength) Return   False ;});
Control. attachevent ( " Onpropertychange " , Function (){ If (Control. value. Length > Maxlength) control. Value = Control. value. substring ( 0 , Maxlength );});



< Script Type = " Text/JavaScript " >
Setmaxlength (OBJ, 500 );



Note about the textarea control for the moment. In the future, I will continue to add some other things about the control.

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.