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 does JS restrict expressions to only enter numbers or numbers and letters

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains the "JS how to limit expressions can only enter numbers or numbers and letters", the text explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "JS how to limit expressions can only enter numbers or numbers and letters" bar!

JS judgment can only be numbers and decimal points.

0. Cannot enter Chinese

1)

1. Text boxes can only enter numeric codes (nor can decimal points)

4. You can only enter letters and Chinese characters

6. You can only enter numbers and English chun

7. There can only be up to two digits after the decimal point (numbers, Chinese can be entered), and letters and operation symbols cannot be entered:

8. There can only be up to two digits after the decimal point (numbers, letters and Chinese can be entered). You can enter operation symbols:

57) event.returnValue = false; "

You can only enter Chinese characters:

Prohibition of Chinese character input method

Only numbers can be entered:

The control input box can only enter words or numbers, or it may not allow you to enter special characters

The following characters are not allowed here: (such as ^ & *, etc.)

Only spaces are prohibited

Onkeyup= "value=value.replace (/ / scompp gjinomaki')"

Onkeydown= "if (event.keyCode==32) return false"

You can only enter Chinese and English:

Onkeyup= "value=value.replace (/ [^ / a-zA-Z/u4E00-/u9FA5] / g a-zA-Z/u4E00-/u9FA5')" onbeforepaste=clipboardData.setData ('text',clipboardData.getData (' text'). Replace (/ [^ / a-zA-Z/u4E00-/u9FA5] / g camera') "

Special characters and spaces are not allowed:

-

Cannot be empty

You can only enter English

-

You can only enter Chinese, English, numbers, @ symbols and. Symbol

You can only enter numbers and periods (note: in [^\ d\.] The d in cannot be capitalized D, otherwise it will become all characters except numbers)

Third, only integers are allowed. In fact, it is entirely possible to impose some restrictions in accordance with Article 3.

The copy code is as follows:

Function onlyNum ()

{

If (! (event.keyCode==46) & &! (event.keyCode==8) & &! (event.keyCode==37) & &! (event.keyCode==39))

If (! (event.keyCode > = 48&&event.keyCode=96&&event.keyCode)

Only Chinese characters are allowed to be input

Only Chinese characters are allowed to be input

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