Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use regular restrictions input box can only enter numbers / English / Chinese and other restrictions

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report