zoukankan      html  css  js  c++  java
  • js验证

    用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;
    }
     
    

      

  • 相关阅读:
    JavaScript.how-to-debug-javascript
    iOS.mach_absolute_time
    Startup.国外新锐公司及其技术Blog
    Android.FamousBlogs
    iOS.PrototypeTools
    Android.API.Context.getFilesDir()
    Android.Tools.Ant
    Tools.OnlineAPIs
    Java.Class
    Android.StructureOfAndroidSourceCodeRootTree
  • 原文地址:https://www.cnblogs.com/freespider/p/2496250.html
Copyright © 2011-2022 走看看