Home >Web Front-end >JS Tutorial >DOM basic tutorial: Using DOM to set text boxes_Basic knowledge
1. Control the number of characters entered by the user
For single-line text boxes and password input boxes, you can use the maxlength attribute to control the number of characters entered by the user.
For multi-line text, maxlength is a custom attribute whose value is the maximum number of characters entered. When the onkeypress event occurs, the return value of the LessThan() function is returned. The function is as follows
Detailed code
2. Set the mouse to automatically select text
The first is to automatically focus when the mouse passes over onmouseover = "this.focus"
The second is onfocus = "this.select()"
Code example:
For multiple code instances, you can use the following code to focus