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

Jquery_联系电话正则表达式

时间:2014-06-18 19:43:26      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   ext   

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 3 <html>
 4 <head>
 5 <title>联系方式正则表达式</title>
 6 <script type="text/javascript" src="js/jquery1.8.min.js"></script>
 7 <script type="text/javascript">
 8 $(function (){
 9     $("#txtPhone").focus(function () {
10         $(this).next().show().removeClass("onError").removeClass("onright").addClass("ontan").html("请输入你的联系电话");
11      }).blur(function () {
12         var patrn = /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$|(^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$)/;
13         if ($(this).val() != ""){
14             if (!patrn.exec($(this).val()))
15                 $(this).next().removeClass("ontan").addClass("onError").html("联系电话格式不正确");
16             else
17                 $(this).next().removeClass("ontan").removeClass("onError").addClass("onright").html("&nbsp;");
18         }
19         else
20             $(this).next().removeClass("ontan").addClass("onError").html("联系电话不能为空");
21     });
22 });
23       
24 </script>
25 </head>
26 <body>
27     <div align="center">
28         联系方式<input type="text" id="txtPhone"/><label style="color: red;" class="onError"></label>
29     </div>
30 </body>
31 </html>

 

Jquery_联系电话正则表达式,布布扣,bubuko.com

Jquery_联系电话正则表达式

标签:style   class   blog   code   java   ext   

原文地址:http://www.cnblogs.com/visec479/p/3790598.html

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