/********************************************************************************************
	Main Comments
	
	Author:  Diane Yocom, Mark Caldwell
	Date:	 5/9/01

	Description:	JavaScript Date Validation routine using Regular Expressions (RegExp).  
					Call isDate in your JavaScript and get True/False returned.  This was 
					extracted from a routine written by Diane Yocom for HSD and placed in 
					the central Code Library by Mark Caldwell.

					To use this routine in your ASP page, insert a line that looks like this:
					<script language="JavaScript" src="/codelib/js/DaveValidation.js"></script>

	Changes:
	mm/dd/yy	inits	Description

********************************************************************************************/

function isDate(strDate) {
	//test that it actually has valid dates, note that 2/29 is not considered to
	//be a valid date. If the reg exp fails, then we'll check for leap years
	var myExp = /(^(01|03|05|07|08|10|12|1|3|5|7|8)\/(0[1-9]|[1-9]|[12][0-9]|3[01])\/(\d\d\d\d|\d\d)$)|(^(04|06|09|11|4|6|9)\/(0[1-9]|[1-9]|[12][0-9]|30)\/(\d\d\d\d|\d\d)$)|(^(02|2)\/(0[1-9]|[1-9]|1[0-9]|2[0-8])\/(\d\d\d\d|\d\d)$)/
	
	if (!myExp.test(strDate)) {
		//If they entered 2/29/xxxx, check if it is a valid leap year
		myExp = /^(02|2)\/(29)\/(\d\d\d\d|\d\d)$/
		if (myExp.test(strDate)) {
			var strYear = strDate.slice(strDate.lastIndexOf("/") + 1)
			if (!((strYear % 4 == 0 && strYear % 100 != 0) || (strYear % 4 == 0 && strYear % 100 == 0 && strYear % 400 == 0))) {
				return (false)
			}
		} else {
			return (false)
		}
	}
	return (true)
}

