function editDate(text,month,day,year,yearLength,required) {
  
  month = trim(month);
  day = trim(day);
  year = trim(year);
  
  //  If it's not required, check if they've
  //  filled in any of the fields.  If so,
  //  edit all the fields
  if (!required) {
    if ((month != '') || (day != '') || (year != '')) {
			editDay(text, month ,day, year);
		  editMonth(text, month );
		  editNumericField(text + ' year', year, yearLength, false);
	  }
	}
  else {  //  It's required, so if any fields
          //  are blank, it's an error.
    if ((month == '') || (day == '') || (year == '')) {
      passed = false;
      errorMessage = errorMessage + text + ' date is required.' + CRLF;
    }
    else {
			editDay(text, month ,day, year);
		  editMonth(text, month );
		  editNumericField(text + ' year', year, yearLength, false);
		}
	}	  
	
}
