How to use regular restrictions input box can only enter numbers / English / Chinese and other restrictions
This article is about how to use the regular restrictions input box to enter only numbers / English / Chinese and other restrictions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Common HTML regular expressions
1. You can only enter numbers and English:
The copy code is as follows:
3. You can only enter full-width:
The copy code is as follows:
5. Email address Verification:
The copy code is as follows:
Var regu =
"^ (([0-9a-zA-Z] +) | ([0-9a-zA-Z] + [_ .0-9a9a-zA-Z ZZ -] * [0-9a-zA-Z] +) @ ([a-zA-Z0-9 -] + [.]) + ([a-zA-Z] {2} | net | NET | COM | gov | GOV | mil | org | ORG | edu | EDU | int | INT) $"
Var re = new RegExp (regu)
If (s.search (re)! =-1) {
Return true
} else {
Window.alert ("Please enter a valid E-mail address!")
Return false
}
6. ID card:
The copy code is as follows:
"^ / d {17} (/ / d | x) $"
7.17 regular expressions
The copy code is as follows:
"^ / / non-negative integer" / / non-negative integer (positive integer + 0)
"^ [0-9] * [1-9] [0-9] * $" / / positive integer
"^ (- / / d+) | (0 +) $" / / non-positive integer (negative integer + 0)
"^-[0-9] * [1-9] [0-9] * $" / / negative integer
"^ -? / / dumped $" / / Integer
"^ / / d + (/ /. / / d +)? $" / / non-negative floating point number (positive floating point number + 0)
"^ (([0-9] + /. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] +) | ([0-9] * [1-9] [0-9] *)) $" / / positive floating point number
"^ ((- / / d+ (/ /. / / d+)?) | (0 + (/ / .0 +)?) $" / / non-positive floating point number (negative floating point number + 0)
"^ (- ([0-9] + /. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] +) | ([0-9] * [1-9] [0-9] *)) $" / / negative floating point
"^ (-? / / d+) (/ /. / / d+)? $" / / floating point number
"^ [A-Za-z] + $" / / A string of 26 letters
"^ [Amurz] + $" / / A string of 26 English letters in uppercase
A string of 26 lowercase letters consisting of "^ [amurz] + $" / /
"^ [A-Za-z0-9] + $" / / A string of numbers and 26 letters
A string of numbers, 26 letters, or underscores
"^ [/ / w -] + (/ /. [/ / w -] +) * @ [/ / w -] + (/ /. [/ / w -] +) + $" / / email address
"^ [a-zA-z] +: / / (/ / w+ (- / / w+) *) (/ /. (/ / w+ (- / / w+) *)) * (/ /? / / S*)? $" / / url
=
1. Cancel the dotted wireframe when the button is pressed
Add an attribute value of hideFocus or HideFocus=true to input
two。 Read-only text box content
Add attribute value readonly to input
3. Prevent backward emptying of TEXT documents (style content can be used as a class reference)
The 4.ENTER key moves the cursor to the next input box
6. Only for numbers (flashing)
The copy code is as follows:
8. You can only enter English and numbers (flashing)
The copy code is as follows:
10. You can only enter numbers, decimal points, minus (-) characters (no flashing)
The copy code is as follows:
11. You can only enter two decimal places and three decimal places (flashing)
The copy code is as follows: