Verify the number by using the JS regular expression.
<Script type = "text/javascript"> function validate () {var reg = new RegExp ("^ [0-9] * $"); var obj = document. getElementById ("name"); if (! Reg. test (obj. value) {alert ("enter a number! ");} If (! /^ [0-9] * $/. test (obj. value) {alert ("enter a number! ") ;}}</Script>
Regular Expression set for verifying numbers
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 + )? $
Js regular expression to verify the number range
/^ (1 [89]) | ([2-7] [0-9]) | (80) $/
Why are you tossing yourself like this? Isn't it easy to judge with num> = 18 & num <= 80?
Verify the regular expression of a number in js
Function isDigit (s)
{
Var patrn =/^ [0-9] {1, 20} $ /;
If (! Patrn.exe c (s) return false
Return true
}