This article mainly introduces the knowledge of JavaScript verification. It has good reference value. Next, let's take a look at it. This article mainly introduces the knowledge of JavaScript verification. It has good reference value. Let's take a look at it with the small Editor.
Javascript can only enter regular expressions such as numbers, numbers, and letters.
1. Only numeric code can be entered in the text box (decimal point cannot be entered)
2. Only numbers can be entered, and decimal points can be entered.
3. Number and decimal point method 2
4. Only letters and Chinese characters can be entered
5. Only English letters and numbers are allowed. Chinese characters are not allowed.
6. Only numbers and English chun numbers can be entered.
7. After the decimal point, you can enter a maximum of two digits (numbers and Chinese characters). You cannot enter letters or operator numbers:
8. A maximum of two digits (numbers, letters, and Chinese characters) can be entered after the decimal point. You can enter the operator number:
Special characters are prohibited:
onKeyPress="if(event.keyCode < 45 || event.keyCode > 57 ) event.returnValue = false;"
Only Chinese characters can be entered:
Style = "ime-mode: disabled" prohibiting Chinese Character Input Methods
Only numbers can be entered:
Only English letters and numbers can be entered:
The control input box can only contain text, numbers, or special characters.
The following characters cannot be entered: (such as ^)
</Pre>Enter spaces only
onkeyup="value=value.replace(//s/g,'')"onkeydown="if(event.keyCode==32) return false"
Only Chinese and English characters can be entered:
onkeyup="value=value.replace(/[^/a-zA-Z/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/a-zA-Z/u4E00-/u9FA5]/g,''))"Special characters and spaces are not allowed:
Cannot be blank
A judgment character consists of letters, numbers, underscores, and periods. It must start with an underscore or letter.
/^([a-zA-z_]{1})([\w]*)$/g.test(str)Only numbers can be entered
Only Chinese characters can be entered
Only English can be entered
Only Chinese characters, English letters, numbers, @ symbols, and. symbols can be entered.
You can only enter English letters, and the paste menu cannot be displayed.
Only numbers and periods can be entered (Note: d in [^ \ d \.] cannot be written as uppercase D, otherwise it will become all characters except numbers)
All in all:Enter onkeyup = "value = value. replace (/[^ \ X]/g, '')" and then in (/[\ X]/g ,'') replace X in with the code you want to enter.
English: u4E00-u9FA5
Number: d, 0-9
English: a-z, A-Z
Other symbols @, point, or other symbols. You can also use multiple symbols and separate them.
For example:
English and numbers plus the @ symbol plus some symbols: \ 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 inEnter onKeyDown = "fncKeyStop (event)" onpaste = "return false" oncontextmenu = "return false ;"
First, only numbers and decimal points are allowed.
Second, the judgment is more detailed, and even 22 .. 2 is not counted as a number.
Script function check () {if (isNaN (tt. value) {alert ("invalid character! "); Tt. value =" ";}} scriptThird, only integers are allowed. In fact, some restrictions can be made based on article 3.