• 各种js验证规则


    /*各类验证lbh*/
    var CheckInput = function(ele){
    	this.eles = $(ele);
    	this.ele = [];
    	var len = this.eles.length;
    	if(len == 0 ){
    		return false;
    	}else if(len == 1){
    		this.ele = this.eles;
    	}else{
    		this.ele = this.eles.eq(0);
    	}
    	this.get_value = function(){
    		var tagname = this.ele[0].tagName.toUpperCase;
    		if( tagname == 'INPUT' || tagname == 'TEXTAREA'){
    			return this.ele.val().trim();
    		}else{
    			return this.ele.html().trim();
    		}
    	}
    };
    
    CheckInput.prototype = {
    	is_email : function(){
    		return /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/.test(this.get_value()) ? true : false;
    	},
    	is_not_null : function(){
    		return !this.get_value() ? true : false;
    	},
    	is_intnumber : function(){
    		return /^[1-9][0-9]*$/.test(this.get_value()) ? true : false;
    	},
    	is_age : function(){
    		var val = parseFloat(this.get_value());
    		return val >= 0 && val <= 150 ? true : false;
    	},
    	is_phone_number : function(){
    		return /^[1-9][8,3,5][0-9]{9}$/.test(this.get_value()) ? true : false;
    	},
    	is_number : function(){
    		/*匹配正整数或正小数*/
    		return /(^0.[0-9]*$)|(^[1-9][0-9]*.[0-9]*$)/.test(this.get_value()) ? true : false;
    	},
    	is_month : function(){
    		return /^(0?[1-9]|1[0-2])$/.test(this.get_value()) ? true : false;
    	},
    	is_day : function(){
    		return /^((0?[1-9])|((1|2)[0-9])|30|31)$/.test(this.get_value()) ? true : false;
    	},
    	is_vaicode : function(){
    		/*六位数字验证码*/
    		return /^[0-9]{6}$/.test(this.get_value()) ? true : false;
    	},
    	is_idcart : function(){
    		return /^d{15}|d{18}$/.test(this.get_value()) ? true : false;
    	}
    }
    

      

  • 相关阅读:
    Hibernate学习笔记1.2(Annotation版本的Helloworld)
    Hibernate学习笔记1.1(简单插入数据)
    Java 分页与原理(上)
    触发器实例讲解
    URLRewrite 实现方法详解
    一个数组:1,1,2,3,5,8,13,21...+m,求第30位数是多少?用递归实现;(常考!!!)
    面向对象
    ajax 判断账户密码 调取数据模糊查询 时钟
    asp.net 类,接口
    asp.net get图
  • 原文地址:https://www.cnblogs.com/gubook/p/5673580.html
Copyright © 2020-2023  润新知