• 正则表达式验证座机号码,手机号等


    用js正则表达式验证手机号,座机号和email格式
    关键字: javascript
    Js代码
    /** 
     *author    zhutou 
     **/ 
     
    //手机号:13912345678  
    function isMobil(s)    
    {    
        var patrn = /^[0-9]{11}$/;  
        if(!patrn.exec(s)) {  
            return false;  
        }  
        return true;  
    }  
     
    //普通座机号:+0086-010-66668888  
    function isTel(s)    
    {    
        var patrn = /^[+]{0,1}(\d){1,4}[ ]{0,1}([-]{0,1}((\d)|[ ]){1,12})+$/;  
        if(!patrn.exec(s)) {  
            return false;  
        }  
        return true;  
    }  
     
    //email:zhutou@163.com  
    function isEmail(s)  
    {  
        var patrn = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;  
        if(!patrn.exec(s)) {  
            return false;  
        }  
        return true;  

    /**
     *author zhutou
     **/

    //手机号:13912345678
    function isMobil(s) 

     var patrn = /^[0-9]{11}$/;
     if(!patrn.exec(s)) {
      return false;
     }
     return true;
    }

    //普通座机号:+0086-010-66668888
    function isTel(s) 

     var patrn = /^[+]{0,1}(\d){1,4}[ ]{0,1}([-]{0,1}((\d)|[ ]){1,12})+$/;
     if(!patrn.exec(s)) {
      return false;
     }
     return true;
    }

    //email:zhutou@163.com
    function isEmail(s)
    {
     var patrn = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;
     if(!patrn.exec(s)) {
      return false;
     }
     return true;
    }
     

  • 相关阅读:
    分布式事务-第一刀
    Qt
    自描述C++部分面试题集
    读书笔记6.21
    STL vector容器 和deque容器
    C++ STL框架
    C++ 多态
    C++ 虚继承
    C++ 类的继承和派生
    C++ 类中的函数重载
  • 原文地址:https://www.cnblogs.com/1003487863qq/p/2846322.html
Copyright © 2020-2023  润新知