Code
1function checkByRegExp(regular, value)
2{
3 if (_isIe)
4 {
Code
1function checkByRegExp(regular, value)
2{
3 if (_isIe)
4 {
5 var re = new RegExp(regular);
6 if (value.match(regular) == null)
7 {
8 return false;
9 }
10 return true;
11 }
12 else
13 {
14 var re = new RegExp(regular);
15 if (!re.exec(value))
16 {
17 return false;
18 }
19 return true;
20 }
21}
22
23或是
24function regcheck(el, reg, msg){ //正则表达式验证
25 var val = el.value;
26 if(!val || !reg.test(val)){
27 alert(msg);
28 el.focus();
29 return false;
30 }
31 return true;
32}
33
34function checknull(el,msg){ //非空验证
35 if(!el.value){
36 alert(msg);
37 el.focus();
38 return false;
39 }
40 return true;
41}
1function checkByRegExp(regular, value)
2{
3 if (_isIe)
4 {
5 var re = new RegExp(regular);
6 if (value.match(regular) == null)
7 {
8 return false;
9 }
10 return true;
11 }
12 else
13 {
14 var re = new RegExp(regular);
15 if (!re.exec(value))
16 {
17 return false;
18 }
19 return true;
20 }
21}
22
23或是
24function regcheck(el, reg, msg){ //正则表达式验证
25 var val = el.value;
26 if(!val || !reg.test(val)){
27 alert(msg);
28 el.focus();
29 return false;
30 }
31 return true;
32}
33
34function checknull(el,msg){ //非空验证
35 if(!el.value){
36 alert(msg);
37 el.focus();
38 return false;
39 }
40 return true;
41}