* 定义验证各种格式类型的正则表达式对象
来源:互联网 发布:计算机基础与c语言 编辑:程序博客网 时间:2024/06/05 11:56
<script src="scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
/**
* 定义验证各种格式类型的正则表达式对象
*/
var Regexs = {
email: (/^[0-9a-z][0-9a-z\-\_\.]+@([0-9a-z][0-9a-z\-]*\.)+[a-z]{2,}$/i),//邮箱
phone: (/^0[0-9]{2,3}[2-9][0-9]{6,7}$/),//座机手机号码
ydphpne: (/^((13[4-9])|(15[012789])|147|182|187|188)[0-9]{8}$/),//移动手机号码
allphpne: (/^((13[0-9])|(15[0-9])|(18[0-9]))[0-9]{8}$/),//所有手机号码
ltphpne: (/^((13[0-2])|(15[56])|(186)|(145))[0-9]{8}$/),//联通手机号码
dxphpne: (/^((133)|(153)|(180)|(189))[0-9]{8}$/),//电信手机号码
url: (/^http:\/\/([0-9a-z][0-9a-z\-]*\.)+[a-z]{2,}(:\d+)?\/[0-9a-z%\-_\/\.]+/i),//网址
num: (/[^0-9]/),//数字
cnum: (/[^0-9a-zA-Z_.-]/),
photo: (/\.jpg$|\.jpeg$|\.gif$/i),//图片格式
row: (/\n/ig)
};
/**
* @return 若符合对应的格式,返回true,否则返回false
*/
function chkFormat(str, ftype) {
var nReg = Regexs[ftype];
if (str == null || str == "") return false; //输入为空,认为是验证通过
if (ftype == 'num') {
if (!nReg.test(str) && !chkChinese(str)) {//10.23 tenfy 必须为数字且不能有中文
return true;
} else {
return false;
}
}
if (!nReg.test(str)) {
return true;
} else {
return false;
}
};
function chkChinese(s) {
for (var i = 0; i < s.length; i++) {
if (s.charCodeAt(i) > 255) return true;
}
return false;
};
</script>
- * 定义验证各种格式类型的正则表达式对象
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- 【转】js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- js 验证各种格式类型的正则表达式
- poi 读取excel 的乱码
- Win7 eclipse Hadoop Failed to set permissions of path
- flex 时间类型转换
- Android的Audio 系统
- mime type 与 dataflavor
- * 定义验证各种格式类型的正则表达式对象
- mysql导入和导出数据库
- 搜索中两种高亮显示方式
- 获得鼠标选中文本的事件兼容多种浏览器
- Java学习循序渐进之private,protected,public,默认修饰的访问权限
- python-mode+emacs24.1的execfile问题解决
- 查询工程中的图片是否被引用 对于后期优化非常有用
- 文件管理
- 程序学习过程中存在的误区