﻿
//时间 	
function IsDate(str) 
{
	var reg=/^\d{4}-[0-1]?\d{1}-[0-3]?\d{1}$/;
	return reg.test(str);
}

function CheckDate(txt1,txt2)
{
	var temp1=txt1.value;
	var temp2=txt2.value;
	if(IsDate(temp1)&&IsDate(temp2))
	{
		temp1=temp1.replace("-","/");
		temp2=temp2.replace("-","/");
		f=new Date(temp1);
		s=new Date(temp2);
		if(f>=s)
		{
				alert("离店日期必须大于入住日期或日期格式不对！")
				return false;
		}
		else if(s.getTime()-f.getTime()>=2419200000)
		{
			alert("如果您需要在酒店入住28天以上，\n请和环网酒店预订中心联系:\n800-820-3777!")
			return false;
		}
		else
		{
			return true;
		}

	}
	else
	{
		alert("日期未输入或格式不对！\n 格式如：2005-12-31");
		return false;
	}		
}

function IsEmail(txt)
{
	var reg=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if(reg.test(txt.value))
	{
	  alert("电子邮箱地址不正确!");
	}
	return reg.test(txt.value);
}

//非空
function IsNull(ctr,msg)
{
	if(ctr.value=="")
	{
		alert(msg);
		ctr.focus();
		return false;
	}
	else
	{
		return true;
	}
}
