function CheckTheDate(INPUTED, OldDate) {
  // Declare and assign variables
  var strFullDate    = INPUTED.value;
  var intDaysInMonth = new Array(12)
  var strMonthName   = new Array(12)
  intDaysInMonth[1]  = 31;    strMonthName[1]  = 'January';
  intDaysInMonth[2]  = 29;    strMonthName[2]  = 'February';
  intDaysInMonth[3]  = 31;    strMonthName[3]  = 'March';
  intDaysInMonth[4]  = 30;    strMonthName[4]  = 'April';
  intDaysInMonth[5]  = 31;    strMonthName[5]  = 'May';
  intDaysInMonth[6]  = 30;    strMonthName[6]  = 'June';
  intDaysInMonth[7]  = 31;    strMonthName[7]  = 'July';
  intDaysInMonth[8]  = 31;    strMonthName[8]  = 'August';
  intDaysInMonth[9]  = 30;    strMonthName[9]  = 'September';
  intDaysInMonth[10] = 31;    strMonthName[10] = 'October';
  intDaysInMonth[11] = 30;    strMonthName[11] = 'November';
  intDaysInMonth[12] = 31;    strMonthName[12] = 'December';

  // Check that a date is passed
  if (!strFullDate == '') {
    //alert('Please enter the date in the format \'dd/mm/yyyy\'.')
	//INPUTED.value = OldDate
	//INPUTED.focus();
    //return false;
  
  
  var strValidDate = /^\d{2}\/\d{2}\/\d{4}$/    //var strValidDate = /^[0-3][0-9]\/[0-1][0-9]\/\d{4}$/
  var blnResult    = strFullDate.match(strValidDate);


  // Check for correct date syntax
  if (!blnResult) {
    alert('The date you have entered is not in a valid format.\n\nPlease enter the date in the format \'dd/mm/yyyy\'.')
	INPUTED.value = OldDate
	INPUTED.focus();
    return false;
  }


  // Extract date values
  var strDay   = strFullDate.substr(0, 2) - 0;
  var strMonth = strFullDate.substr(3, 2) - 0;
  var strYear  = strFullDate.substr(6, 4) - 0;


  // Handle the month
  if ((strMonth < 1) || (strMonth > 12)) {
    alert('The month you have entered is invalid.\n\nPlease correct the problem and try again.')
	INPUTED.value = OldDate
	INPUTED.focus();
    return false;
  }


  // Handle days in month
  var intDayInMonth = intDaysInMonth[strMonth];
  var strMonthTitle = strMonthName[strMonth];
  if ((strDay < 1) || (strDay > intDayInMonth)) {
    alert('The day you have specified for the date in the month of ' + strMonthTitle + ' is invalid.\n\nPlease correct the problem and try again.')
	INPUTED.value = OldDate
	INPUTED.focus();
    return false;
  }


  // Handle leap years
  if ((strDay == 29) && (strMonth == 2) && ((strYear % 4) == 0)) {
    if (strYear % 400 == 0) {
      return true;
    } else if (strYear % 100 == 0) {
      alert('The day you have specified for the date in the month of ' + strMonthTitle + ' is invalid.\n\nPlease correct the problem and try again.')
	  INPUTED.value = OldDate
	  INPUTED.focus();
      return false;
    } else {
      return true;
    }
  } else if ((strDay == 29) && (strMonth == 2) && ((strYear % 4) != 0)) {
    alert('The day you have specified for the date in the month of ' + strMonthTitle + ' is invalid.\n\nPlease correct the problem and try again.')
	INPUTED.value = OldDate
	INPUTED.focus();
    return false;
  } else {
    return true;
  }

	} //if not empty

} //end function

