复制代码 代码如下:
var validator = { 
// 邮箱 
isemail : function(s) { 
var p = ^[-!#$%&\'*+\\./0-9=?a-z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?a-z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?a-z^_`a-z{|}~]+$; 
return this.test(s, p); 
},
// 手机号码 
ismobile : function(s) { 
return this.test(s, /^(180|189|133|134|153|181)\d{8}$/); 
},
// 电话号码 
isphone : function(s) { 
return this.test(s, /^[0-9]{3,4}\-[0-9]{7,8}$/); 
},
// 邮编 
ispostcode : function(s) { 
return this.test(s, /^[1-9][0-9]{5}$/); 
},
// 数字 
isnumber : function(s, d) { 
return !isnan(s.nodetype == 1 ? s.value : s) 
&& (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$')); 
},
// 判断是否为空 
isempty : function(s) { 
return !jquery.isemptyobject(s); 
},
// 正则匹配 
test : function(s, p) { 
s = s.nodetype == 1 ? s.value : s; 
return new regexp(p).test(s); 
} 
};
   
 
   