1/**/
8function checkInput(_obj,type,errmsg,flag){
9 var reg;
10 var obj = $(_obj.id);
11 var info = $(_obj.id+"Info");
12 switch(type){
13 case 'isEmpty':
14 reg = /^\S+$/;
15 break;
16 case 'isEmail':
17 reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
18 break;
19 case 'isPostCode':
20 reg = /^\d{6}$/;//国内的六位邮编格式
21 break;
22 case 'isTell':
23 reg = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/; //手机号码或区号-电话;
24 break;
25 case "isUserName":
26 reg = /^\w+$/;//字母开头,允许数字,字母和下划线
27 break;
28 case "isEnglish":
29 reg = /^[a-z]{3,20}$/;
30 break;
31 case "isNumber":
32 reg =/^[1-9]\d*$/;
33 break;
34 case "indexChar":
35 reg=/^[A-Z]$/
36 break;
37 case "isUrl":
38 reg=/^\S+$/;
39 break;
40 }
41 //提交表单或失去焦点进行验证
42 if(flag){
43 if(reg.test(trim(obj.value))==false){
44 info.innerHTML ="<font color='red'>× "+errmsg+"</font>";
45 return false;}
46 else{
47 info.innerHTML ="<font color='green'>√</font>";
48 return true;}
49 }
50 //获得焦点时进行提示
51 else{
52 info.innerHTML ="<font color='blue'>"+errmsg+"</font>";
53 }
54}
55function $(_id){
56 return document.getElementById(_id);
57}
58//去掉开始和结束的空格
59function trim(string){ return string.replace(/(^\s*)|(\s*$)/g,"");}
8function checkInput(_obj,type,errmsg,flag){
9 var reg;
10 var obj = $(_obj.id);
11 var info = $(_obj.id+"Info");
12 switch(type){
13 case 'isEmpty':
14 reg = /^\S+$/;
15 break;
16 case 'isEmail':
17 reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
18 break;
19 case 'isPostCode':
20 reg = /^\d{6}$/;//国内的六位邮编格式
21 break;
22 case 'isTell':
23 reg = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/; //手机号码或区号-电话;
24 break;
25 case "isUserName":
26 reg = /^\w+$/;//字母开头,允许数字,字母和下划线
27 break;
28 case "isEnglish":
29 reg = /^[a-z]{3,20}$/;
30 break;
31 case "isNumber":
32 reg =/^[1-9]\d*$/;
33 break;
34 case "indexChar":
35 reg=/^[A-Z]$/
36 break;
37 case "isUrl":
38 reg=/^\S+$/;
39 break;
40 }
41 //提交表单或失去焦点进行验证
42 if(flag){
43 if(reg.test(trim(obj.value))==false){
44 info.innerHTML ="<font color='red'>× "+errmsg+"</font>";
45 return false;}
46 else{
47 info.innerHTML ="<font color='green'>√</font>";
48 return true;}
49 }
50 //获得焦点时进行提示
51 else{
52 info.innerHTML ="<font color='blue'>"+errmsg+"</font>";
53 }
54}
55function $(_id){
56 return document.getElementById(_id);
57}
58//去掉开始和结束的空格
59function trim(string){ return string.replace(/(^\s*)|(\s*$)/g,"");}