码迷,mamicode.com
首页 > 移动开发 > 详细

正则表达式判断手机号是否11位数字

时间:2017-06-02 11:25:48      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:php   class   正则   func   html   this   手机号码   test   val   

function checkMobile(str) { //写一个判断函数
     
    var  re = /^1\d{10}$/    //正则表达式
    if (re.test(str)) {      //判断字符是否是11位数字
		  $("#sj").html("手机号码格式正确");
		  $("#sj").css("color","green"); 
    } 
	else {
          $("#sj").html("手机号码格式错误");
		  $("#sj").css("color","red"); 
    }
}
$("#tel").blur(function(){
		var str = $(this).val(); //取值
		checkMobile(str);
})

 

正则表达式判断手机号是否11位数字

标签:php   class   正则   func   html   this   手机号码   test   val   

原文地址:http://www.cnblogs.com/yi11/p/6931827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!