This article summarizes how to use js to determine that only numbers and letters can be entered for verification. For more information, see
JS judgment can only be a number or a decimal point
0. Chinese characters cannot be entered
1)
2) script
Function chkIt (frm ){
If (frm. n1.value. length> 0 & frm. n1.value. match (/[\ x01-\ xFF] */) = false ){
Alert ('n1 cannot input Chinese! ')
Frm. n1.focus ();
Return false;
}
}
Script
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:
57) & event. keyCode! = 46 |/\. \ d $/. test (value) event. returnValue = false ">
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 ^)
32 & event. keyCode <48) | (event. keyCode> 57 & event. keyCode <65) | (event. keyCode> 90 & event. keyCode <97) event. returnValue = false; ">
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
---------------------------------------
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:
57) & event. keyCode! = 46 | //./d $/. test (value) event. returnValue = false ">
8. A maximum of two digits (numbers, letters, and Chinese characters) can be entered after the decimal point. You can enter the operator number:
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 replace X in (/[\ X]/g, ") 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 separate them.
For example:
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 inInput 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 = "";}
}
Script
Third, only integers are allowed. In fact, some restrictions can be made based on article 3.