  
  
  function isDateMDY1(formObj)
{
	var objVal = formObj.value;
	var regExpDate =/^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/; 
	var regExpDateDash = /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/; 



	if(regExpDate.test(objVal) == false)
	{
		if(regExpDateDash.test(objVal) == false)
		{
			// alert("Improper format");
			return false;
		}
	}
	var firstsep=0;
	var lastsep=0;
	firstsep = formObj.value.indexOf("/");
	if(firstsep == -1)
	{
		firstsep = formObj.value.indexOf("-");
		lastsep = formObj.value.lastIndexOf("-");
	}
	else
	{
		lastsep = formObj.value.lastIndexOf("/");
	}

	var monthValue  = "";
	var dateValue   = "";
	var yearValue   = "";
	var testChar    = "";
	var nLen = formObj.value.length;

	for (i=0; i < firstsep; i++)
	{
		testChar = objVal.charAt(i);
		if (testChar < '0' || testChar > '9')
		{
		
			// alert("date: testChar < '0' || testChar > '9'");
			return false;
		}
		monthValue += objVal.charAt(i);
	}
	
	for (i=firstsep + 1; i < lastsep; i++)
	{
		testChar = objVal.charAt(i);
		if (testChar < '0' || testChar > '9')
		{
			alert("month: testChar < '0' || testChar > '9'");
			return false;
		}
		dateValue += objVal.charAt(i);
	}
	
	for (i=lastsep + 1; i < nLen; i++)
	{
		testChar = objVal.charAt(i);
		if (testChar < '0' || testChar > '9')
		{
			alert("year: testChar < '0' || testChar > '9'");
			return false;
		}
		yearValue += objVal.charAt(i);
	}
	
	var testDate   = new Date(yearValue, monthValue - 1, dateValue);
//  var testDate = new Date(Date.parse(objVal));
	
	var newMonth   = (testDate.getMonth()) + 1;
	var newDate	   = testDate.getDate();
	var newYear	   = (testDate.getYear()+ 1900);// + 1900;
	
	// alert(newDate + "-" + newMonth + "-" + newYear);
	

	if ((monthValue == newMonth) &&
		(dateValue  == newDate) &&
		(yearValue  == newYear))
		return true;
	else
	{
// alert("!((monthValue == newMonth) && (dateValue  == newDate) && (yearValue == newYear))");
		return false;
	}
}
  
  
  
// check the validity of the name. returns false if the string is empty 
function checkname(formobj)
{    
	formobj.value= trimtxt(formobj);  
	if  (isBlank(formobj))
	{
		formobj.focus();
		alert("Please enter your name");
		return false;
	}
	return true;
} // end of checkname function
	
	  
// check for the validity of Email address. Only 1 '@' and atleast one '.' 
// is required in the address string. 
function checkemail(formobj)
{
	formobj.value = trimtxt(formobj);
		if (!isEmail(formobj))
		{ 
			formobj.focus();
			alert("Please enter a valid Email Address. Example - yourname@hotmail.com");
			return false;
		}
		return true;
}  // end of checkmail function
	   
// check the length of the message field 
function checkmsg(formobj)
{  
	var charlength = formobj.value.length;
  
	if  (charlength > 1000)
		{
			formobj.focus();
			alert("Your message is too long -- maximum 1000 characters. You entered " + charlength + " characters.");
			return false;
		}
	return true;
} // end of checkmsg function

		
// check the validity of the datee. returns false if the string is not mm/dd/yyyy 
function checkdate(formobj)
{    
	formobj.value= trimtxt(formobj);  

	if  (isDateMDY1(formobj))
	
	{
		
	return true;
	}
	else
	{
		formobj.focus();
		alert("Please enter date in mm/dd/yyyy format");
		return false;
	}
} // end of function
	

	
	
	
	
	
	
// form level validation for all the fields. 
function checkform()
{ 

	if (!checkemail(document.form1.email)				
		|| !checkname(document.form1.first_name)		
		|| !checkmsg(document.form1.message)
		|| !checkdate(document.form1.appt_date)
	
		)
	{
		return false;
	}
	return true;
} // end of function checkform