The input input box restricts different situations

1. Restrict the input input box to only input uppercase and lowercase letters, numbers, and underscore regular expressions:

<el-input type="text" onkeyup="this.value=this.value.replace(/[^\w_]/g,'');"> 

2. Restrict the input input box to only input lowercase letters, numbers, and underscore regular expressions:

<el-input type="text" onkeyup="this.value=this.value.replace(/[^a-z0-9_]/g,'');"> 

3...Restrict the input input box to a regular expression that can only enter numbers and points:

<el-input type="text" onkeyup="value=value.replace(/[^\d.]/g,'')">

4. Limit the input box to only input Chinese regular expressions:

<el-input type="text" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')">  

5. A regular expression that restricts the input box to only input numbers:

<el-input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')">  

6. Limit the input box to only input English regular expressions:

<el-input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z]/g,'')">

7. Restrict the input box to only input Chinese, numbers, and English regular expressions:

<el-input onkeyup="value=value.replace(/[^\w\u4E00-\u9FA5]/g, '')">  

8. A regular expression that restricts the input box to only input numbers and letters:

<el-inputt onKeyUp="value=value.replace(/[\W]/g,'')">  

9. Restrict the input box except for English punctuation marks, the other can be Chinese, English letters, numbers, regular expressions of Chinese punctuation:

<el-input type="text" onkeyup="this.value=this.value.replace(/^[^!@#$%^&*()-=+]/g,'')">

10. A regular expression that restricts the input input box to only input numeric codes (decimal points are not allowed):

<el-input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">

11. The regular expression that restricts the input input box to only input numbers and decimal points:

<el-input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">

<el-input name=txt1 onchange="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}">

or

<el-input type=text t_value="" o_value="" onkeypress="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onkeyup="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onblur="if(!this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/))this.value=this.o_value;else{if(this.value.match(/^\.\d+$/))this.value=0+this.value;if(this.value.match(/^\.$/))this.value=0;this.o_value=this.value}">

12 Regular expressions that limit the input input box to only input letters and Chinese characters:

<el-input onkeyup="value=value.replace(/[\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))" maxlength=10 name="Numbers">

13. Limit the input input box to only input English letters and numbers, not Chinese regular expressions:

<el-input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">

14 Restrict the input input box to only enter numbers and English regular expressions:

<el-input onKeyUp="value=value.replace(/[^\d|chun]/g,'')">

15 Limit the input box to only have a maximum of two digits after the decimal point (numbers and Chinese can be entered), and regular expressions that cannot input letters and operation symbols:

<el-input onKeyPress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false">

16. Limit the input box to only have a maximum of two digits after the decimal point (numbers, letters, and Chinese can be entered), and you can enter the regular expression of the operation symbol:

<el-input onkeyup="this.value=this.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')">

17. Cannot input Chinese

<el-input  onkeyup="this.value=this.value.replace(/[\u4E00-\u9FA5]/g,'')">

18. Spaces are not allowed

<el-input onkeyup="onkeyup="value = value.replace(/\s+/g, '')">

Guess you like

Origin blog.csdn.net/qq_43532275/article/details/130809057