// Check whether it is composed of digits
Copy codeThe Code is as follows:
Function isDigit (s)
{
Var patrn =/^ [0-9] {1, 20} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Check Logon Name: You can enter only 5-20 strings starting with a letter, which can contain numbers, "_", and ".".
Copy codeThe Code is as follows:
Function isRegisterUserName (s)
{
Var patrn =/^ [a-zA-Z] {1} ([a-zA-Z0-9] | [. _]) {} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Check user name: only 1-30 strings starting with letters can be entered
Copy codeThe Code is as follows:
Function isTrueName (s)
{
Var patrn =/^ [a-zA-Z] {1, 30} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Password verification: only 6-20 letters, numbers, and underscores can be entered
Copy codeThe Code is as follows:
Function isPasswd (s)
{
Var patrn =/^ (w) {6, 20} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Verify the phone number and fax number. The phone number can start with "+" and contain "-" in addition to numbers.
Copy codeThe Code is as follows:
Function isTel (s)
{
// Var patrn =/^ [+] {0, 1} (d) {1, 3} []? ([-]? (D) {1, 12}) + $ /;
Var patrn =/^ [+] {0, 1} (d) {1, 3} []? ([-]? (D) | []) {1, 12}) + $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Verify the mobile phone number. It must start with a number and can contain "-" in addition to a number.
Copy codeThe Code is as follows:
Function isMobil (s)
{
Var patrn =/^ [+] {0, 1} (d) {1, 3} []? ([-]? (D) | []) {1, 12}) + $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Verify the zip code
Copy codeThe Code is as follows:
Function isPostalCode (s)
{
// Var patrn =/^ [a-zA-Z0-9] {3, 12} $ /;
Var patrn =/^ [a-zA-Z0-9] {} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Verify the search keyword
Copy codeThe Code is as follows:
Function isSearch (s)
{
Var patrn =/^ [^ '~! @ # $ % ^ & * () + = | \] [] {}:; ',. <>/?] {1} [^ '~! @ $ % ^ & () + = | \] [] {}:; ',. <>?] {0, 19} $ /;
If (! Patrn.exe c (s) return false
Return true
}
// Check whether the IP address is used
Copy codeThe Code is as follows:
Function isIP (s) // by zergling
{
Var patrn =/^ [0-9.] {1, 20} $ /;
If (! Patrn.exe c (s) return false
Return true
}
Copy codeThe Code is as follows:
"^ \ 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 + (\. \ d + )? $ "// 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 + (\. \ d + )?) | (0 + (\. 0 + )?)) $ "// 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 +) (\. \ d + )? $ "// 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 digits, 26 letters, or underscores
"^ [\ W-] + (\. [\ w-] +) * @ [\ w-] + (\. [\ w-] +) + $ "// email address
"^ [A-zA-z] +: // (\ w + (-\ w + )*)(\. (\ w + (-\ w + )*))*(\? \ S *)? $ "// Url
"^ [A-Za-z0-9 _] * $"