Today, there is a problem, how to limit the length of the user input in the fixed-width input input box, which is covered by the MaxLength property and the Size property and their differences.

Source: Internet
Author: User

The first thing you want to do is to force the hidden in one line and beyond. Another idea is how to link the length of value and the length of the box, and I don't know how to contact them.

In solving another problem, my brother sent me the code inadvertently see input has a maxlength attribute, the property is checked here.

In W3school, it says that the MaxLength property has two maximum values: 85 and 55, which is used for type text and password properties. Specifically why there are two maximum values is unclear, unknown origin.

The difference between maxlength and size is, for example:

Maxlength= "5", only 5 characters can be entered in the input box
Size= "5", which indicates that input box only shows 5 visible characters, but you can enter ' countless ' multi-character content
That is: The Size property specifies the width of the input field (where the Name2 text box only displays a width of 5 characters)

as follows, the length of input with the Size property written is 5 characters long, and the width below is not set significantly longer than the size equal to 5, that is, the size is visualized.

<input type= "Text" size= "5" ><br>
<input type= "Text" >


Because the Size property is a visual design property, we should use the width in the CSS instead.
CSS syntax: <input style= "width:100px"/>

Take the value of this property in JavaScript and note the second letter capitalized:readonly <====> readonly

Today, there is a problem, how to limit the length of the user input in the fixed-width input input box, which is covered by the MaxLength property and the Size property and their differences.

Related Article

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.