
// Check whether string s is empty.
function isEmpty(s) {
    return ((s == null) || (s.length == 0));
}
    
function isInbetween(low, middle, high)
{
    return (low <= middle) && (middle <= high);
}

function isValidDate(year, month, day) 
{
    if ( ! isInbetween(2000, year, 2030) ||
	 ! isInbetween(1,    month,  12) ||
	 ! isInbetween(1,    day,    31)   ) 
      {
	  return false;
      }
    switch ( parseInt(month) )
      {
	case 2:
	  var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	  if ( day > (isleap ? 29 : 28) ) return false;
	  break;
	case 4: case 6: case 9: case 11:
	  if ( day > 30 ) return false;
	  break;
      }
    return true;
}

