zoukankan      html  css  js  c++  java
  • Jquery_联系电话正则表达式

     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>
  • 相关阅读:
    数据库
    多并发之协程
    坚持就是胜利
    线程
    python—函数
    pycharm—项目文件下的子目录的删除
    python—字符串连接方式
    python—字符串的切割
    pycharm教程
    python—迭代
  • 原文地址:https://www.cnblogs.com/visec479/p/3790598.html
Copyright © 2011-2022 走看看