Verification number: ^ [0-9] * $
Verify the n-digit number: ^ \ D {n} $
Verify at least N digits: ^ \ D {n,} $
Verify M-N digits: ^ \ D {m, n} $
Verify the number starting with zero or zero: ^ (0 | [1-9] [0-9] *) $
Verify the positive number of two decimal places: ^ [0-9] + (. [0-9] {2 })? $
Verify the positive number of 1-3 decimal places: ^ [0-9] + (. [0-9] {1, 3 })? $
Verify a non-zero positive integer: ^ \ +? [1-9] [0-9] * $
Verify a non-zero negative integer: ^ \-[1-9] [0-9] * $
Verify non-negative integer (positive integer + 0) ^ \ D + $
Verify non-positive integer (negative integer + 0) ^ (-\ D +) | (0 +) $
3 characters for verification: ^. {3} $
Verify a string consisting of 26 English letters: ^ [A-Za-Z] + $
Verify a string consisting of 26 uppercase letters: ^ [A-Z] + $
Verify a string consisting of 26 lower-case letters: ^ [A-Z] + $
Verify a string consisting of digits and 26 English letters: ^ [A-Za-z0-9] + $
Verify a string consisting of digits, 26 English letters, or underscores: ^ \ W + $
Verify User Password: ^ [A-Za-Z] \ W {5, 17} $ the correct format is: it must start with a letter and be between 6 and 18 characters. It can only contain characters, numbers, and underscores.
Check whether ^ % & ',; =? $ \ "And other characters: [^ % & ',; =? $ \ X22] +
Verify Chinese characters: ^ [\ u4e00-\ u9fa5], {0,} $
Verify email address: ^ \ W + [-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $
Verify interneturl: ^ http: // ([\ W-] + \.) + [\ W-] + (/[\ W -./? % & =] *)? $; ^ [A-Za-Z] +: // (W + (-W +) *) (. (W + (-W + )*))*(? S *)? $
Verification phone number: ^ (\ D {3, 4} \) | \ D {3, 4 }-)? \ D {7,8} $: -- the correct format is: XXXX-XXXXXXX, XXXX-XXXXXXXX, XXX-XXXXXXX, XXX-XXXXXXXX, xxxxxxx, XXXXXXXX.
Verify the ID card number (15 or 18 digits): ^ \ D {15} | \ D {} 18 $
12 months of verification: ^ (0? [1-9] | 1 [0-2]) $ the correct format is: "01"-"09" and "1" "12"
31 days of verification for a month: ^ (0? [1-9]) | (1 | 2) [0-9]) | 30 | 31) $ the correct format is: 01, 09, 1, 31.
Integer: ^ -? \ D + $
Non-negative floating point number (Positive floating point number + 0): ^ \ D + (\. \ D + )? $
Positive floating point number ^ ([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $
Non-Positive floating point number (negative floating point number + 0) ^ (-\ D + (\. \ D + )?) | (0 + (\. 0 + )?)) $
Negative floating point number ^ (-([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $
Floating Point Number ^ (-? \ D +) (\. \ D + )? $
×××××××××××××××××××××××××××××××××××××××××
The following are not tested. Please verify and use
1. Only numbers and English letters can be entered:
<Input onkeyup = "value = value. replace (/[\ W]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')" id = "text1" name = "text1">
2. Only numbers can be entered:
<Input onkeyup = "value = value. replace (/[^ \ D]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')" id = "text2" name = "text2">
3. Only the fullwidth fields can be entered:
<Input onkeyup = "value = value. replace (/[^ \ uff00-\ Uffff]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ uff00-\ Uffff]/g, '')" id = "text3" name = "text3">
4. Only Chinese characters can be entered:
<Input onkeyup = "value = value. replace (/[^ \ u4e00-\ u9fa5]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ u4e00-\ u9fa5]/g, '')" id = "text4" name = "text4">
5. Email address verification:
VaR regu = "^ ([0-9a-za-z] +) | ([0-9a-za-z] + [_. 0-9a-za-z-] * [0-9a-za-z] +) @ ([a-zA-Z0-9-] + [.]) + ([A-Za-Z] {2} | net | com | Gov | mil | org | Edu | int |) $"
VaR Re = new Regexp (regu );
If (S. Search (re )! =-1 ){
Return true;
} Else {
Window. Alert ("enter a valid and valid email address! ")
Return false;
}
6. ID card:
"^ \ D {17} (\ d | x) $"
7.17 Regular Expressions
"^ \ D + $" // 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
"^ -? \ D + $ "// integer
"^ \ D + ([url = file: //. // D + )? $] \. \ D + )? $ [/Url] "// 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 + ([url = file: //. // D + )?) % 7C (0 + (//. 0 + )?)) $] \. \ D + )?) | (0 + (\. 0 + )?)) $ [/Url] "// 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 number
"^ (-? \ D +) ([url = file: //. // D + )? $] \. \ D + )? $ [/Url] "// floating point number
"^ [A-Za-Z] + $" // a string consisting of 26 English letters
"^ [A-Z] + $" // a string consisting of 26 uppercase letters
"^ [A-Z] + $" // a string consisting of 26 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 letters
"^ \ W + $" // a string consisting of a number, 26 English letters, or underscores
"^ [\ W-] + (\\. [\ W-] +) * @ [\ W-] + (\\. [\ W-] +) + $ "// email address
"^ [A-Za-Z] +: // (\ W + (-\ W + )*)(\\. (\ W + (-\ W + )*))*(\\? \ S *)? $ "// URL
========================================================== =====
1. The dotted box when the cancel button is pressed
Add the attribute value hidefocus or hidefocus = true in input.
2. Read-only text box content
Add the attribute value readonly in input.
3. Prevent text files from being cleared (style content can be referenced as a class)
<Input style = behavior: URL (# default # savehistory); type = text id = opersistinput>
4. Press enter to move the cursor to the next input box.
<Input onkeydown = "If (event. keycode = 13) event. keycode = 9">
5. It can only be Chinese (with flashing)
<Input onkeyup = "value ="/value. Replace (/["-~] /G, '')" onkeydown = "If (event. keycode = 13) event. keycode = 9">
6. Only numbers are allowed (with flashing)
<Input onkeyup = "value ="/value. replace (/["^ \ D]/g,'') "onbeforepaste =" clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')">
7. Only numbers are allowed (no flashing)
<Input ime-mode: Disabled "onkeydown =" If (event. keycode = 13) event. keycode = 9 "onkeypress =" If (event. keycode <48 | event. keycode> 57) event. returnvalue = false ">
8. Only English and numbers can be entered (with flashing)
<Input onkeyup = "value ="/value. replace (/[\ W]/g, "'') "onbeforepaste =" clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')">
9. shielded Input Method
<Input type = "text" name = "url" ime-mode: Disabled "onkeydown =" If (event. keycode = 13) event. keycode = 9 ">
10. You can only enter numbers, decimal points, minus (-) characters (no flashing)
<Input onkeypress = "If (event. keycode! = 46 & event. keycode! = 45 & (event. keycode <48 | event. keycode> 57) event. returnvalue = false ">
11. Only two decimal places can be entered, and three decimal places (with flashing)
<Input maxlength = 9 onkeyup = "If (value. match (/^ \ D {3} $/) value = "/value. replace (value, parseint (value/10) "; value ="/value. replace (/\. \ D *\. /g ,'. "')" onkeypress = "If (event. keycode <48 | event. keycode> 57) & event. keycode! = 46 & event. keycode! = 45 | value. match (/^ \ D {3 }$/) | /\. \ D {3} $ /. test (value) {event. returnvalue = false} "id = text_kfxe name = text_kfxe>
"^ \ D + $" // 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
"^ -? \ D + $ "// integer
"^ \ D + ([url = file: // \. \ D + )? $] \. \ D + )? $ [/Url] "// 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 + ([url = file: // \. \ D + )?) | (0 + (\. 0 + )?)) $] \. \ D + )?) | (0 + (\. 0 + )?)) $ [/Url] "// 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 number
"^ (-? \ D +) ([url = file: // \. \ D + )? $] \. \ D + )? $ [/Url] "// floating point number
"^ [A-Za-Z] + $" // a string consisting of 26 English letters
"^ [A-Z] + $" // a string consisting of 26 uppercase letters
"^ [A-Z] + $" // a string consisting of 26 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 letters
"^ \ W + $" // a string consisting of a number, 26 English letters, or underscores
"^ [\ W-] + (\\. [\ W-] +) * @ [\ W-] + (\\. [\ W-] +) + $ "// email address
"^ [A-Za-Z] +: // (\ W + (-\ W + )*)(\\. (\ W + (-\ W + )*))*(\\? \ S *)? $ "// URL
"^ (\ D {1, 3} (, \ D {3 })*?) | \ D +) (\. \ D + )? $ // Decimal with commas
Specific Use
<Script language = JavaScript>
VaR Mm =/^ \ D + $ /;
Function formcheck ()
{
If (! Mm. Test (document. f1.propertyamount. Value ))
{
Alert ("enter a valid number ");
Document. f1.propertyamount. Focus ();
Return false;
}
Return true;
}
</SCRIPT>