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
Preface There are many ways to center horizontall...
There are three ways to represent colors in HTML, ...
CSS Styles html,body{ width: 100%; height: 100%; ...
Configuration Preface Project construction: built...
Table of contents Class component event binding F...
Don't be surprised if you see some kind of und...
Firefox, Opera and other browsers do not support W...
Step 1: Add a secondary domain name to the Alibab...
ChunkFive Free Typefamily Cuprum JAH I Free font Y...
This article describes the MySQL transaction mana...
This tutorial explains how to verify the IP addre...
Preface In many cases, we will use virtual machin...
Here are some points to note when registering Tom...
When using the MySQL database, if you have not lo...
The following is my judgment based on the data st...