JQuery验证工具类搜集整理

时间:2013-01-16    点击:84   
复制代码 代码如下:

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);
}
};
jQuery插件开发基础简单介绍
jQuery旋转插件—rotate支持(ie/Firefox/SafariOpera/Chrome)
用JS提交参数创建form表单在FireFox中遇到的问题
体验js中splice()的强大(插入、删除或替换数组的元素)
js 在定义的时候立即执行的函数表达式(function)写法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved