Copy code code as follows:
<script type = "text/javascript">
function value () {
var reg = new regexp ("^[0-9]*$");
var obj = document.GetelementByid ("name");
if (! reg.Test (obj.value)) {
alert ("Please enter numbers!");
}
if (!/^[0-9]*$/. Test (obj.value)) {
alert ("Please enter numbers!");
}
}
</script>
Verify the regular expression set of numbers
Verification number:^[0-9]*$
Verify N -bit numbers:^/d {n} $
Verify at least n digits:^/d {n,} $
Verify the number of mn bits:^/d {m, n} $
Verify zero and non-zero numerals:^(0 | [1-9] [0-9]*) $
Verify the positive number of two decimals:^[0-9]+(. [0-9] {2})? $
Verify the positive number of 1-3 decimals:^[0-9]+(. [0-9] {1,3})? $
Verify non-zero positive integer:^/+? [1-9] [0-9]*$
Verify non-zero negative integers:^/-[1-9] [0-9]*$
Verify non -negative integer (positive integer+ 0) ^/d+ $
Verify non-positive integer (negative integer+0) ^((-/d+) | (0+)) $
Delivers with a verification length of 3:^. {3} $
Verify string consisting of 26 English letters:^[A-ZA-Z]+$
Verify string consisting of 26 capital letters:^[az]+$
Verify string consisting of 26 lowercase English letters:^[az]+$
Verify string consisting of numbers and 26 English letters:^[A-ZA-Z0-9]+$
Verify string consisting of numbers, 26 English letters, or underlined lines:^/w+$
Verify user password:^[a-za-z]/w {5,17} $ Correct format: Beginning with the letter, the length is between 6-18, and can only include characters, numbers, and subordinate lines.
Verify whether it contains^%& ',; =? $/"And other characters: [^%&',; =? $/X22]+
Verify Chinese characters:^[/u4e00-/u9fa5], {0,} $
Verify the email address:^/w+[-+.]/W+)*@/w+([-.]/W+)*/./W+([-.]/W+)*$
Verify interneturl:^http: // ([/w-]+/.)+[/W-]+(/[/w-./?%&=]*)? $; ]+: // (w+(-w+)*) (. (w+(-w+)*))*(? S*)? $
Verification phone number:^(/(/d {3,4}/) |/d {3,4}-)?/D {7,8} $:-The correct format is: xxxx-xxxxxxx, xxxx-xxxxxxxxxxxx , Xxx-xxxxxxx, xxx-xxxxxxxx, xxxxxxx, xxxxxxxx.
Verify ID number (15 digits or 18 digits):^/d {15} |/d {} 18 $
Verify 12 months of a year:^(0? [1-9] | 1 [0-2]) The correct format is: "01"-"09" and "1" and "12"
Verify 31 days a month:^((0? [1-9]) | ((1 | 2) [0-9]) | 30 | 31) $ Correct format: 01, 09 and 1, 31.
Interaction:^-?/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+)?)) $
The number of negative floating points^(-([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+)? $