Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does JS restrict expressions to only enter numbers or numbers and letters

Shulou Source: shulou.com Published: 2022-06-02 05:22:59 10月03日 Update

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

Tags: Input numbers letters English codes Chinese symbols characters decimals decimal points restrictions Chinese characters expressions special underscores learning content text methods spaces Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Microsoft Xiaomi vpn