//判断数字及长度
function isNum(string,length,declength){
	if(isNaN(string)){
		return false;
	}else{
		if(length!=null){
			if(string.length>length){
				return false;
			}else{
				if(declength!=null&&string.split(".").length==2&&string.split(".")[1].length>declength){
					return false;
				}
			}
		}
	}
	return true;
}
//判断email格式及长度
function isEmail(string){
	var splitted = string.match("^(.+)@(.+)$");
	if(splitted == null) return false;
	if(splitted[1] != null ){
		var regexp_user=/^\"?[\w-_\.]*\"?$/;
		if(splitted[1].match(regexp_user) == null) return false;
	}
	if(splitted[2] != null){
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
		if(splitted[2].match(regexp_domain) == null){
			var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
			if(splitted[2].match(regexp_ip) == null) return false;
		}
		return true;
	}
	return false;
}
//判断电话及长度isTel(STRING,[NUMBER])
function isTel(string,length){
	base = "0123456789-";
	for(i = 0;i<=string.length-1;i++){
		if( base.indexOf(string.substring(i, i+1)) == -1  ){
			return false;
			break;
		}
	}
	if(length!=null&&string.length>length){
		return false;
	}
	return true;
}
//判断是否有特殊字符
function isSpe(string){
	base = "~!*#+=;'?@#$%\\/[]{}";
	for(i = 0;i<base.length;i++){
		if( string.indexOf(base.substring(i, i+1)) != -1  ){
			return false;
			break;
		}
	}
	return true;
}

//判断非空
function isNull(string){
	if(string==""){
		return false;
	}
	return true;
}
//判断整数和长度
function isInt(string,length){
	base = "0123456789";
	for(i = 0;i<=string.length-1;i++){
		if( base.indexOf(string.substring(i, i+1)) == -1  ){
			return false;
			break;
		}
	}
	if(length!=null&string.length>length){
		return false;
	}
	return true;
}
//判断日期
function isDate(string,length){
	if(length==10 && string.search(/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29))$/)!=-1){
		return true;
	}else if(length=8 && string.search(/^((((1[6-9]|[2-9]\d)\d{2})(0?[13578]|1[02])(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})(0?[13456789]|1[012])(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})0?2(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))0?229))$/)!=-1){
		return true;
	}else if(length==10 && string.search(/^((((1[6-9]|[2-9]\d)\d{2})\/(0?[13578]|1[02])\/(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})\/(0?[13456789]|1[012])\/(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})\/0?2\/(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\/0?2\/29))$/)!=-1){
		return true;
	}else
		return false;
}
//判断时间
function isTime(string){
	if(string.search(/^([01]?\d|2[0-3])\:[0-5]?\d\:[0-5]?\d$/)!=-1)
		return true;
	else
		return false;
}
//判断日期时间
function isDateTime(string){
	if(string.search(/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/)!=-1)
		return true;
	else if(string.search(/^((((1[6-9]|[2-9]\d)\d{2})\/(0?[13578]|1[02])\/(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})\/(0?[13456789]|1[012])\/(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})\/0?2\/(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\/0?2\/29)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/)!=-1)
		return true;
	else
		return false;
}
//判断字符串长度
function isStringLong(string,length){
	if(string.length<=length)
		return true;
	else
		return false;
}
//判断0或1
function isBoolean(string){
	if(string=="0"||string=="1")
		return true;
	else
		return false;
}
