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

Teach you how to achieve vertical centering elegantly (recommended)

Preface There are many ways to center horizontall...

Implementation of HTML sliding floating ball menu effect

CSS Styles html,body{ width: 100%; height: 100%; ...

React event binding details

Table of contents Class component event binding F...

Use pictures to realize personalized underline of hyperlinks

Don't be surprised if you see some kind of und...

How to support Webdings fonts in Firefox

Firefox, Opera and other browsers do not support W...

Use nginx + secondary domain name + https support

Step 1: Add a secondary domain name to the Alibab...

33 of the best free English fonts shared

ChunkFive Free Typefamily Cuprum JAH I Free font Y...

Detailed explanation of mysql transaction management operations

This article describes the MySQL transaction mana...

Commands to find domain IP address in Linux terminal (five methods)

This tutorial explains how to verify the IP addre...

Complete steps to configure a static IP address for a Linux virtual machine

Preface In many cases, we will use virtual machin...

Summary of some points to note when registering Tomcat as a service

Here are some points to note when registering Tom...

Linux MySQL root password forgotten solution

When using the MySQL database, if you have not lo...

Optimized implementation of count() for large MySQL tables

The following is my judgment based on the data st...