﻿//----------------------------------------------------------------
// Copyright (C) 2006 中国数码集团
// 版权所有。 
//
// 文件名：Validate.js
// 文件功能描述：数据验证
//
// 
// 创建标识：简相辉20070208
// 修改标识：赵国宏20070401
//----------------------------------------------------------------

///
///数据验证类
///
function Validater(Auto)
{
	var basicValidater = new SimpleValidater();
	
	this.Auto = false | Auto;//true 自动处理，false 自定义处理。
	
	this.laoheValidate = function(ctrlId,limitedvalue,ctrlExplain)
    {
        if(!limitedvalue) limitedvalue = -1;
        if(!ctrlExplain) ctrlExplain = -1;
        var chkCtrl = document.getElementById(ctrlId);
        var value = ctrlId;
        if (typeof(value) != undefined || value != null || value != "")
        {
            if(chkCtrl != undefined && chkCtrl != null)
            {
                value = ValidateTools.prototype.Trim(chkCtrl.value);
            }
            var result = true;
            if(value == limitedvalue)
            {
                alert(ctrlExplain);
                result = false;
            }
        }
        if (chkCtrl != undefined && chkCtrl != null) 
		{
			chkCtrl.hideFocus = true;
			chkCtrl.focus();
			chkCtrl.select();
			
		}
        return result;
    }
	
	this.Validate = function(ctrlId,validateItems,ctrlExplain,maxLength,minLength,maxBinaryLength,maxValue,minValue)
	{
		if (!maxBinaryLength) maxBinaryLength = -1;
		if (!maxLength) maxLength = -1;
		if (!minLength) minLength = -1;
		if (!maxValue) maxValue = -1;
		if (!minValue) minValue = -1;
		
		var chkCtrl = document.getElementById(ctrlId);
		var value = ctrlId;
		var diavalue = ctrlId;

		if (chkCtrl != undefined && chkCtrl != null)
		{
			if(chkCtrl.tagName!="SELECT")
			{
			value = ValidateTools.prototype.Trim(chkCtrl.value);
			}
			if(chkCtrl.tagName=="SELECT")
			{
			diavalue =chkCtrl.selectedIndex;
			}
		}
		
		var result = true;
		var validateItem;
		
		// E 输入项不能为空
		if (result && validateItems.indexOf("E") != -1)
		{
			validateItem = "E";
			result = !basicValidater.IsNull(value);
		}
		
		if(result && validateItems.indexOf("O") != -1)
		{
		    validateItem = "O";
		    result = basicValidater.IsDropDownList(diavalue);
		}

		if(result && validateItems.indexOf("r") != -1)
		{
		    validateItem = "r";
		    result = basicValidater.IsPasswordFormat(diavalue);
		}
		// N 无符号数字
		if (result && validateItems.indexOf("N") != -1)
		{
			validateItem = "N";
			result = basicValidater.IsNumber(value);
		}
		if(result && validateItems.indexOf("p") != -1)
		{
		    validateItem = "p";
		    result = basicValidater.IsPostCord(value);
		}
		
		// G 有符号数字
		if (result && validateItems.indexOf("G") != -1)
		{
			validateItem = "G";
			result = basicValidater.IsSignNumber(value);
		}
		
		//g 输入项为各种名称（英文小写、数字）
		if(result && validateItems.indexOf("g") != -1)
		{
		    validateItem = "g";
		    result = basicValidater.IsWordAndNum(value);
		}
		
		// F 无符号浮点数
		if (result && validateItems.indexOf("F") != -1)
		{
			validateItem = "F";
			result = basicValidater.IsFloat(value);
		}
		
		// H 有符号浮点数
		if (result && validateItems.indexOf("H") != -1)
		{
			validateItem = "H";
			result = basicValidater.IsSignFloat(value);
		}
		
		// W 英文字母
		if (result && validateItems.indexOf("W") != -1)
		{
			validateItem = "W";
			result = basicValidater.IsLetter(value);
		}
		
		// C 汉字
		if (result && validateItems.indexOf("C") != -1)
		{
			validateItem = "C";
			result = basicValidater.IsChinese(value);
		}
		
		// D 日期格式
		if (result && validateItems.indexOf("D") != -1)
		{
			validateItem = "D";
			result = basicValidater.IsDate(value);
		}
		
		// M 电子邮件格式
		if (result && validateItems.indexOf("M") != -1)
		{
			validateItem = "M";
			result = basicValidater.IsEMail(value);
		}
		
		// I URL格式
		if (result && validateItems.indexOf("I") != -1)
		{
			validateItem = "I";
			result = basicValidater.IsUrl(value);
		}
		
		// U 全角
		if (result && validateItems.indexOf("U") != -1)
		{
			validateItem = "U";
			result = basicValidater.IsSBCEncode(value);
		}
		
		// A 半角
		if (result && validateItems.indexOf("A") != -1)
		{
			validateItem = "A";
			result = basicValidater.IsDBCEncode(value);
		}
		
		// R 英数字
		if (result && validateItems.indexOf("R") != -1)
		{
			validateItem = "R";
			result = basicValidater.IsLettrNumeric(value);
		}
		
		// Q 不能为纯数字
		if (result && validateItems.indexOf("Q") != -1)
		{
			validateItem = "Q";
			result = basicValidater.IsNoAllNumber(value);
		}
		//J 输入项为电话（只能是座机可含3－6位分机号）
		if (result && validateItems.indexOf("J") != -1)
		{
			validateItem = "J";
			result = basicValidater.IsOnlyTel(value);
		}
		
		//T 输入项为电话（含手机小灵通）
		if (result && validateItems.indexOf("T") != -1)
		{
			validateItem = "T";
			result = basicValidater.IsTel(value);
		}
		//K 输入项手机或小灵通
		if (result && validateItems.indexOf("K") != -1)
		{
			validateItem = "K";
			result = basicValidater.IsMobile(value);
		}
		//X 输入项时间截止必须大于今天的日期（时间控件或格式2007－01－01）
		if (result && validateItems.indexOf("X") != -1)
		{
			validateItem = "X";
			result = basicValidater.UntilNowDate(value);
		}
		//P 输入项时间必须小于今天的日期（时间控件或格式2007－01－01）
		if (result && validateItems.indexOf("P") != -1)
		{
			validateItem = "P";
			result = basicValidater.BeforeNowDate(value);
		}
		//Y 输入项15位或18位身份证号
		if (result && validateItems.indexOf("Y") != -1)
		{
			validateItem = "Y";
			result = basicValidater.IsIDCard(value);
		}
		if(result && validateItems.indexOf("f") != -1)
		{
		    validateItem = "f";
		    result = basicValidater.IsIDCardAll(value);
		}
		if (result && validateItems.indexOf("j") != -1)
		{
			validateItem = "j";
			result = basicValidater.IsImage(value);
		}
		//Z 输入项为各种名称（英文小写、汉字、数字、下划线不能数字或下划线开头）
		if(result && validateItems.indexOf("Z") != -1)
		{
		    validateItem = "Z";
		    result = basicValidater.IsNameFormat(value);
		}
		
		//h 输入项为各种名称（英文小写、汉字、数字、回车换行符、下划线不能数字或下划线以及回车换行符开头）
		if(result && validateItems.indexOf("h") != -1)
		{
		    validateItem = "h";
		    result = basicValidater.IsNameFormatIncludeEnter(value);
		}
		
		if(result && validateItems.indexOf("z") != -1)
		{
		    validateItem = "z";
		    result = basicValidater.NoAllNumber(value);
		}
		
		//S 小数点后保留两位
		if (result && validateItems.indexOf("S") != -1)
		{
			validateItem = "S";
			result = basicValidater.IsPriceNumber(value);
		}
		
		// L 长度限制
		if (result && validateItems.indexOf("L") != -1)
		{
			validateItem = "L";
			result = basicValidater.CheckLength(value,maxLength,minLength);
		}
		
		// B 字节长度限制
		if (result && validateItems.indexOf("B") != -1)
		{
			validateItem = "B";
			result = basicValidater.CheckBinaryLength(value,maxBinaryLength);
		}
		
		// V 范围限制
		if (result && validateItems.indexOf("V") != -1)
		{
			validateItem = "V";
			result = basicValidater.CheckValueRange(value,maxValue,minValue);
		}
		
		//统一处理，如果验证失败且设置为自动处理
		if (!result && this.Auto)
		{
			AutoProcess(validateItem,chkCtrl,ctrlExplain,maxBinaryLength,maxLength,minLength,maxValue,minValue);
		}
		
		return result;
	}
	
	//验证失败自动处理
	function AutoProcess(validateItem,control,ctrlExplain,maxBinaryLength,maxLength,minLength,maxValue,minValue)
	{
		var itemMessage = "";
		var isAffix;
		
		switch (validateItem)
		{
		    case "p":
		        itemMessage = yz1;
		        break;
			case "E" :
				itemMessage = yz3;
				break;
			case "j" :
				itemMessage = yz4;
				break;
			case "N" :
				itemMessage = yz7;
				break;
			case "g" :
				itemMessage = yz42;
				break;
			case "G" :
				itemMessage = yz6;
				break;
			case "F" :
				itemMessage = yz7;
				break;
			case "H" :
				itemMessage = yz8;
				break;
			case "W" :
				itemMessage = yz9;
				break;
			case "C" :
				itemMessage = yz10;
				break;
			case "r" :
				itemMessage = yz41;
				break;
			case "O" :
				itemMessage = yz11;
				break;
			case "M" :
				itemMessage = yz12;
				break;
			case "I" :
				itemMessage = yz13;
				break;
			case "U" :
				itemMessage = yz14;
				break;
			case "A" :
				itemMessage = yz15;
				break;
			case "D" :
				itemMessage = yz16;
				break;
			case "R" :
				itemMessage = yz17;
				break;
			case "Q" :
				itemMessage = yz18;
				break;
			case "T" :
				itemMessage = yz19;
				break;
			case "K" :
				itemMessage = yz20;
				break;
			case "J" :
				itemMessage = yz21;
				break;
			case "X" :
				itemMessage = yz22;
				break;
			case "P" :
				itemMessage = yz23;
				break;
			case "Y" :
				itemMessage = yz24;
				break;
			case "f":
				itemMessage = yz25;
				break;
			case "Z" :
				itemMessage = yz26;
				break;
			case "h" :
				itemMessage = yz26;
				break;
			case "z":
			    itemMessage = yz27;
			    break;
			case "S" :
				itemMessage = yz29;
				break;
			case "L" :
				itemMessage = yz30;

				isAffix = true;
				
				if (maxLength < 0)
				{
					isAffix = false;
				}

				if (isAffix)
				{
					itemMessage = itemMessage + yz33 + maxLength + yz34;
				}

				if (minLength > 0)
				{	
					itemMessage = itemMessage + yz32 + minLength + yz34;
				}				

				break;
			case "B" :
				itemMessage = yz2;

				if (maxBinaryLength > 0)
				{
					itemMessage = itemMessage + yz33 + maxBinaryLength + yz35;
				}

				break;
			case "V" :
				itemMessage = yz36;

				isAffix = true;
				
				if (maxValue < 0)
				{
					isAffix = false;
				}

				if (isAffix)
				{
					itemMessage = itemMessage + yz37 + maxValue;
				}

				if (minValue > 0)
				{
					if (isAffix)
					{
						itemMessage += "，";
					}

					itemMessage = itemMessage + yz38 + minValue + "。";
				}
				else
				{
					itemMessage += "。";
				}

				break;
			default :
				itemMessage = yz31;
				break;
		}

		if (ctrlExplain != "")
		{
			itemMessage = ctrlExplain + itemMessage;
		}

		alert(itemMessage);//警告用户
		
		if (control != undefined && control != null) //控件获得焦点
		{
			control.hideFocus = true;
			control.focus();
			if(control.tagName!="SELECT")
			{
			    control.select();
			}
		}
	}
}

///
///验证工具类
///
function ValidateTools()
{
}

/// <summary>
/// 去两端空格
/// </summary>
/// <param name="trimText">要去空格的字符串</param>
ValidateTools.prototype.Trim = function(trimText)
{
	return ValidateTools.prototype.TrimEnd(ValidateTools.prototype.TrimStart(trimText)); 
}

/// <summary>
/// 去左空格
/// </summary>
/// <param name="trimText">要去空格的字符串</param>
ValidateTools.prototype.TrimStart = function(trimText)
{ 
	return trimText.replace( /^\s*/, ""); 
} 

/// <summary>
/// 去右空格
/// </summary>
/// <param name="trimText">要去空格的字符串</param>
ValidateTools.prototype.TrimEnd = function(trimText)
{ 
	return trimText.replace( /\s*$/, ""); 
}  


///
///简单验证类
///
function SimpleValidater()
{
	/// <summary>
	/// 验证输入项是否为null、""
	/// </summary>
	/// <param name="value">需要验证的数据</param>
	/// <returns>如果数据为空，返回true，否则返回false</returns>
	this.IsNull = function(value)
	{
		if (typeof(value) == undefined || value == null || value == "")
		{
			return true;
		}
		
		return false;
	}
	
	//正则表达式验证
	this.RegexMatch = function(value,regex)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var result =  value.match(regex);
		
		if (result)
		{
			return true;
		}
		
		return false;
	}
	
		
	this.UntilNowDate = function(value,regex)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var datenow=new Date();
		var curyear=datenow.getFullYear();
		var curmonth=datenow.getMonth()+1;
		var turnmonth=new String(curmonth);
		if(turnmonth.length<2)
		{
		    turnmonth='0'+turnmonth;
		}
		var curdate=datenow.getDate();
		var turndate=new String(curdate);
		if(turndate.length<2)
		{
		    turndate='0'+turndate;
		}
		var curtime=curyear+'-'+turnmonth+'-'+turndate;
		var criteriontime=curtime.replace(/\D/g,'');
		var equatsdate=value.replace(/\D/g,'');
		var equats=false;
		if(equatsdate>=criteriontime)
		{
		    equats=true;
		}
		else
		{
		    equats=false;
		}
		var result = equats;
		
		if (result)
		{
			return true;
		}
		
		return false;
	}
	
	this.BeforeNowDate = function(value,regex)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var datenow=new Date();
		var curyear=datenow.getFullYear();
		var curmonth=datenow.getMonth()+1;
		var turnmonth=new String(curmonth);
		if(turnmonth.length<2)
		{
		    turnmonth='0'+turnmonth;
		}
		var curdate=datenow.getDate();
		var turndate=new String(curdate);
		if(turndate.length<2)
		{
		    turndate='0'+turndate;
		}
		var curtime=curyear+'-'+turnmonth+'-'+turndate;
		var criteriontime=curtime.replace(/\D/g,'');
		var equatsdate=value.replace(/\D/g,'');
		var equats=false;
		if(equatsdate<criteriontime)
		{
		    equats=true;
		}
		else
		{
		    equats=false;
		}
		var result = equats;
		
		if (result)
		{
			return true;
		}
		
		return false;
	}
	
	this.NoRegexMatch = function(value,regex)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var result =  value.match(regex);
		
		if (!result)
		{
			return true;
		}
		
		return false;
	}
	
	this.IsDropDownList = function(value)
	{
	   var vilidrop = false;
	   if(value>0)
	   {
	       vilidrop = true;
	   }
	   else
	   {
	       vilidrop = false;
	   }
	   if(vilidrop)
	   {
	       return true;
	   }
	   return false;
	   
	}
	//无符号整数
	this.IsNumber = function(value)
	{
		return this.RegexMatch(value,/(^0{1,1})$|(^[1-9]{1,1}[0-9]*)$/);
	}
	
	this.IsImage = function(value)
	{
		return this.RegexMatch(value,/\.jpg$|\.jpeg$|\.gif$|\.png$|\.bmp$/);
	}
	
	this.IsPostCord = function(value)
	{
	    return this.RegexMatch(value,/^[0-9]{1,1}[0-9]{5,5}$/);
	}
	
	
	this.IsNoAllNumber = function(value)
	{
		return this.NoRegexMatch(value,/^((\d+$)|(\d+\.{1,1}\d+$)|(\d+\.$))/);
	}
	
	this.IsIDCard = function(value)
	{
	    return this.RegexMatch(value,/^(([1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|([1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$))/);
	}
	
	this.IsIDCardAll = function(value)
	{
	    return this.RegexMatch(value,/^(([a-z]+)|([\u4e00-\u9fa5]+)|([1-9]*))(|([0-9]*)|_*|-*)*[0-9]+$/);
	}
	
	this.IsNameFormat = function(value)
	{
	    return this.RegexMatch(value,/^(([a-z]+)|([A-Z]+)|([\u4e00-\u9fa5]+)|([0-9]+)|_+|-+)(([a-z]*)|([A-Z]+)|([\u4e00-\u9fa5]*)|([0-9]*)|_*|-*)*(([a-z]*)|([A-Z]+)|([\u4e00-\u9fa5]*)|([0-9]*)|_*|-*)*$/);
	}
	
	this.IsNameFormatIncludeEnter = function(value)
	{
	    return this.RegexMatch(value,/^(([a-z]+)|([A-Z]+)|([\u4e00-\u9fa5]+)|([0-9]+)|_+|-+)(([a-z]*)|([A-Z]+)|([\u4e00-\u9fa5]*)|([0-9]*)|_*|-*|((\r)*|(\n)*|(\r\n)*|(\s)*))*(([a-z]*)|([A-Z]+)|([\u4e00-\u9fa5]*)|([0-9]*)|_*|-*)*$/);
	}
	
	this.IsPasswordFormat = function(value)
	{
	    return this.RegexMatch(value,/^(([a-z]+)|([0-9]*)|_+|\.+)(([a-z]*)|([0-9]*)|_*|\.*)*(([a-z]*)|([0-9]*)|_*|\.*)*$/);
	}
	this.NoAllNumber = function(value)
	{
	    return this.RegexMatch(value,/^[^0-9]+$/);
	}
	
	//截止时间
	this.IsCheckDate = function(value)
	{
	    return this.ReRegexMatch(value);
	}
	

	this.IsPriceNumber = function(value)
	{
		//return this.RegexMatch(value,/(^((0{1,1})|([1-9]{1,1}\d*))\.(([1-9]{1,1})|([0-9]{1,1}[1-9]{1,1}))$)|((^0{1,1})$|(^[1-9]{1,1}[0-9]*)$)/);
		return this.RegexMatch(value,/(^((0{1,1}\.(([1-9]{1,1})|([0-9]{1,1}[1-9]{1,1}))$)|([1-9]{1,1}\d*\.\d{1,2}$)))|((^0{1,1})$|(^[1-9]{1,1}[0-9]*)$)/);
	}
	
	//有符号整数
	this.IsSignNumber = function(value)
	{
		return this.RegexMatch(value,/^[+-]?([1-9]{1,1}\d*)$/);
	}
	
	//电话号码
	this.IsTel = function(value)
	{
		return this.RegexMatch(value,/(^((\d{3,4})|\d{3,4}-)?((\d{3,4})|\d{3,4}-)?\d{7,8}(-\d{3,6})*$)|(^\d{11,12}$)/);
	}
	
	this.IsWordAndNum = function(value)
	{
	    return this.RegexMatch(value,/^(([0-9]+)|([A-Z]+)|([a-z]+))+(([0-9]+)|([A-Z]+)|([a-z]+))*(([0-9]+)|([A-Z]+)|([a-z]+))*$/);
	}
	
	this.IsMobile = function(value)
	{
		return this.RegexMatch(value,/^\d{11,12}$/);
	}
	
	this.IsOnlyTel = function(value)
	{
		return this.RegexMatch(value,/^((\d{3,4})|\d{3,4}-)?\d{7,8}(-\d{3,6})*$/);
	}
	
	//无符号浮点数
	this.IsFloat = function(value)
	{
		return this.RegexMatch(value,/^((0{1,1})|([1-9]{1,1}\d*))\.[0-9]*[1-9]+$/);
	}
	
	//有符号浮点数
	this.IsSignFloat = function(value)
	{
		return this.RegexMatch(value,/^[+-]?(0{1,1}|([1-9]{1,1}\d*))\.[0-9]*[1-9]+$/);
	}
	
	//英文
	this.IsLetter = function(value)
	{
		return this.RegexMatch(value,/^[A-Za-z]+$/);
	}
	
	//中文
	this.IsChinese = function(value)
	{
		return this.RegexMatch(value,/^[\u4e00-\u9fa5]+$/);
	}
	
	//EMail
	this.IsEMail = function(value)
	{
		return this.RegexMatch(value,/\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*/);
	}
	
	//日期
	this.IsDate = function(value)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var result = value.match(/(^\d{1,2}(-){1,1}\d{1,2}(-){1,1}\d{4}$)|(^\d{4}(-){1,1}\d{1,2}(-){1,1}\d{1,2}$)/);
		
		if (result)
		{
			var dpart = value.match(/\d+/g);
		
			if (dpart[0].length == 4) // YYYY MM DD 
			{
				if (dpart[1] > 12)
				{
					return false;
				}
				
				result = CheckDay(dpart[0],dpart[1],dpart[2]);
			}
			else  //MM DD YYYY
			{
				if (dpart[0] > 12)
				{
					return false;
				}
				
				result = CheckDay(dpart[2],dpart[0],dpart[1]);
			}
			
			return result;
		}
		
		return false;
	}
	
	//URL
	this.IsUrl = function(value)
	{
		return this.RegexMatch(value,/^((http|https|ftp):\/\/)?([\w-]+\.)+[a-zA-Z]+(\/[\w- \.\/?%&=]*)?$/);
	}
	
	//全角
	this.IsSBCEncode = function(value)
	{
		var binaryLength = GetBinaryLength(value);
		
		if (value.length > 0 && value.length * 2 != binaryLength)
		{
			return false;
		}
		
		return true;
	}
	
	//半角
	this.IsDBCEncode = function(value)
	{
		var binaryLength = GetBinaryLength(value);
		
		if (value.length > 0 && value.length != binaryLength)
		{
			return false;
		}
		
		return true;
	}
	
	//英数字
	this.IsLettrNumeric = function(value)
	{
		return this.RegexMatch(value,/^([a-zA-Z])\w*([a-zA-Z0-9])*$/);
	}
	
	//长度
	this.CheckLength = function(value,maxLength,minLength)
	{
		var newValue = value.replace("\r\n","");
		
		if (this.IsNull(newValue))
		{
			return true;
		}
		
		var result = true;
		
		if (maxLength > 0 && newValue.length > maxLength)
		{
			result = false;
		}
		
		if (result && minLength > 0 && newValue.length < minLength)
		{
			result = false;
		}
		
		return result;
	}
	
	//字节长度
	this.CheckBinaryLength = function(value,maxLength)
	{
		if (this.IsNull(value))
		{
			return true;
		}
		
		var binaryLength = GetBinaryLength(value);
		
		if (maxLength > 0 && binaryLength > maxLength)
		{
			return false;
		}
		
		return true;
	}
	
	//取值范围
	this.CheckValueRange = function(value,maxValue,minValue)
	{
		if (this.IsNull(value) && !isNaN(value))
		{
			return true;
		}
		
		var result = true;
		var nValue = parseFloat(value);
		
		if (maxValue > 0 && nValue > maxValue)
		{
			result = false;
		}
		
		if (result && minValue > 0 && nValue < minValue)
		{
			result = false;
		}
		
		return result;
	}
	
	//计算字节长度
	function GetBinaryLength(value)
	{
		var len = 0;
	
		for (var i = 0; i < value.length; i++) 
		{
			var c = value.charCodeAt(i);
			if ( (c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) 
			{
				len += 1;
			} 
			else 
			{
				len += 2;
			}
		}
		
		return len;
	}
	
	//检查日期是否合法
	function CheckDay(yearPart,monthPart,dayPart)
	{
		var days = 0;

		if (monthPart == 2) //2月天数
		{
			if (((yearPart % 4 == 0) && (yearPart % 100 != 100)) || (yearPart % 400 == 0)) 
			{
				days = 29;
			}
			else 
			{
				days = 28;
			}
		}
		else if (monthPart == 4 || monthPart == 6 || monthPart == 9 || monthPart == 11) //小月的天数
		{
			days = 30;
		}
		else //大月的天数
		{
			days = 31;
		}
		
		if (days < dayPart)
		{
			return false;
		}
		
		return true;
	}
}