What does input type mean and how to limit input

What does input type mean and how to limit input
Common methods for limiting input
1. To cancel the dotted box when the button is pressed, add the attribute value hideFocus or HideFocus=true in the input

Copy code
The code is as follows:

<input type="submit" value="Submit" hidefocus="true" />

2. To read only the text box content, add the attribute value readonly in input

Copy code
The code is as follows:

<input type="text" readonly />

3. Prevent the TEXT document from being cleared after going back (the style content can be used as a class reference)

Copy code
The code is as follows:

<input type="text" style="behavior:url(#default#savehistory);" />

4. The ENTER key moves the cursor to the next input box

Copy code
The code is as follows:

<input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" />

5. Only Chinese (flashing)

Copy code
The code is as follows:

<input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" />

6. Only numbers (flashing)

Copy code
The code is as follows:

<input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />

7. Only numbers (no flashing)

Copy code
The code is as follows:

<input type="text" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" onkeypress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />

8. Only English and numbers can be entered (with flashing)

Copy code
The code is as follows:

<input type="text" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />

9. Block input method

Copy code
The code is as follows:

<input type="text" name="url" style="ime-mode: disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" />

10. Only numbers, decimal points, and minus signs (-) can be entered (no flashing)

Copy code
The code is as follows:

<input onkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />

11. Only two decimal places or three decimal places can be entered (flashing)

Copy code
The code is as follows:

<input type="text" maxlength="9" onkeyup="if(value.match(/^\d{3}$/))value=value.replace(value,parseInt(value/10)) ;value=value.replace(/\.\d*\./g,'.')" onkeypress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 && event.keyCode!=45 || value.match(/^\d{3}$/) || /\.\d{3}$/.test(value)) {event.returnValue=false}" />

<<:  The principle and configuration of Nginx load balancing and dynamic and static separation

>>:  Facebook's nearly perfect redesign of all Internet services

Recommend

80 lines of code to write a Webpack plugin and publish it to npm

1. Introduction I have been studying the principl...

Summary of various implementation methods of mysql database backup

This article describes various ways to implement ...

MySQL 8 new features: Invisible Indexes

background Indexes are a double-edged sword. Whil...

How to ensure that every page of WeChat Mini Program is logged in

Table of contents status quo Solution Further sol...

Some points on using standard HTML codes in web page creation

<br />The most common mistake made by many w...

How to solve the timeout during pip operation in Linux

How to solve the timeout problem when pip is used...

The webpage cannot be opened because the div element lacks a closing tag

At first I thought it was a speed issue, so I late...

MySQL 5.6.27 Installation Tutorial under Linux

This article shares the installation tutorial of ...

Start nginxssl configuration based on docker

Prerequisites A cloud server (centOS of Alibaba C...

Detailed explanation of incompatible changes in rendering functions in Vue3

Table of contents Rendering API changes Render fu...

Detailed explanation of common for loop in JavaScript statements

There are many loop statements in JavaScript, inc...