---
title: "js正则表达式匹配校验手机号码"
author: "喧嚣求静"
date: "2011-11-01T17:09:41Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2012-03-13T12:50:46Z"
id: 1226894
url: "https://913.iteye.com/blog/1226894"
---

扩展jquery.validate

```js

/*
 * 中国移动号段大全：

2G手机号段大全：134、135、136、137、138、139、150、151、152、157、158、159；

3G手机号段大全：182、187、188；

中国联通号段大全：

2G手机号段大全：130、131、132、155、156；

3G手机号段大全：185、186；

中国电信号段大全：

2G手机号段大全：133、153；

3G手机号段大全：180、189
 * 2011-10-31 
 * author LiuDong
 * */
$.validator.addMethod('isMobile', function(value, element) {
	var length = value.length;
    return this.optional(element) || length == 11 &&
            /^13[0-9]{1}[0-9]{8}$|^15[012356789]{1}[0-9]{8}$|^18[0256789]{1}[0-9]{8}$/.test(value);
}, '请输入有效的手机号码');

```

使用示例

```js


$(function() {
		  
			$('#frmCustomerInfo').validate({
				rules: {
					'customer.contactTel': {
						digits: true,
						isMobile:"#customer.contactTel"
						 //range:
					}
				},
				messages: {
					'tel': '请输入目前有效手机号(数字且为11位！)'
				}
			});		
		});	


```


JS正则表达式大全
http://www.blogjava.net/onejavaer/articles/79070.html