Summary of character types input in the js control text box, and js text box
Only numbers can be entered in the JS control text box.
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ 0-9]/g, '')" onpaste = "value = value. replace (/[^ 0-9]/g, '')" oncontextmenu = "value = value. replace (/[^ 0-9]/g, '')">
Javascript control text box can only enter numbers, decimal points
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ 0-9 \.] /g, '')" onpaste = "value = value. replace (/[^ \ 0-9 \.] /g, '')" oncontextmenu = "value = value. replace (/[^ \ 0-9 \.] /g, '')">
Javascript control text box can only be entered in English
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z]/g, '')" onpaste = "value = value. replace (/[^ \ a-\ z \ A-\ Z]/g, '')" oncontextmenu = "value = value. replace (/[^ \ a-\ z \ A-\ Z]/g, '')">
Only English and numbers can be entered in the JS control text box.
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9]/g, '')" onpaste = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9]/g, '')" oncontextmenu = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9]/g, '')">
The JS control text box can only enter Chinese Characters
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ u4E00-\ u9FA5]/g, '')" onpaste = "value = value. replace (/[^ \ u4E00-\ u9FA5]/g, '')" oncontextmenu = "value = value. replace (/[^ \ u4E00-\ u9FA5]/g, '')">
The JS control text box can only contain Chinese characters, English letters, and numbers.
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5]/g, '')" onpaste = "value = value. replace (/[^\ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5]/g, '')" oncontextmenu = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5]/g, '')">
The JS control text box can only contain Chinese characters, English letters, numbers, and spaces.
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \]/g, '')" onpaste = "value = value. replace (/[^\ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \]/g, '')" oncontextmenu = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \]/g, '')">
The javascript control text box can only contain Chinese characters, English letters, numbers, and decimal places.
Copy codeThe Code is as follows:
<Input onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \.] /g, '')" onpaste = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \.] /g, '')" oncontextmenu = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \.] /g, '')">
All in all:
First input in '<input>'
Onkeyup = "value = value. replace (/[^ \ X]/g ,'')"
Then replace X in (/[\ X]/g, '') with the code you want to enter,
Chinese u4E00-u9FA5, number 0-9, English a-z \ A-Z, other symbols @, point or other symbols.
You can also use \ To separate multiple.
For example: Chinese and English + numbers + @ symbol + dot symbol \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \@\.
If you do not want to right-click the menu in the text box or paste the copied information
In '<input>', enter onpaste = "return false" oncontextmenu = "return false ;"