JQuery验证工具类

来源:互联网 发布:有趣的数据统计 编辑:程序博客网 时间:2024/05/29 21:33
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);}};


<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>