
function isValidDate(ctrlDate)
{
	var d = new Date();
	var nCurrent_Year = d.getFullYear();
	if (ctrlDate.value == '') return true;
	d.setTime(Date.parse(ctrlDate.value));
	if (isNaN(d) || d.getFullYear() < 1900 || d.getFullYear() > (nCurrent_Year+5))
	{
		alert("Date format should be 'MM/DD/YYYY'.");
		ctrlDate.value = '';
		ctrlDate.focus();
		return false;
	}
	else
	{
		ctrlDate.value = formatShortDate(d);
		return true;
	}
}

function formatShortDate(d)
{
  var cDate  = '';
  var nDays  = d.getDate();
  var nMonth = d.getMonth()+1;
  var nYear  = d.getFullYear();
  if (nYear < 1920) nYear += 100;

  cDate += ((nMonth < 10) ? '0' : '') + nMonth + '/' + ((nDays < 10) ? '0' : '') + nDays + '/' + nYear;

  return cDate;
}

<!-- Original:  Sandeep Tamhankar (stamhankar@hotmail.com) -->
<!-- Web Site:  http://207.20.242.93 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function isValidTime(ctrl)
{
	var timeStr = ctrl.value;

	if (timeStr == '')
		return true;
		
	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null)
	{
		alert("Time is not in a valid format.");
		return false;
	}

	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second == "") { second = null; }
	if (ampm == "") { ampm = null }

	if (hour < 0  || hour > 23)
	{
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	if (hour <= 12 && ampm == null)
	{
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time"))
		{
			alert("You must specify AM or PM.");
			return false;
	   	}
	}

	if  (hour > 12 && ampm != null)
	{
		alert("You can't specify AM or PM for military time.");
		return false;
	}

	if (minute<0 || minute > 59)
	{
		alert ("Minute must be between 0 and 59.");
		return false;
	}

	if (second != null && (second < 0 || second > 59))
	{
		alert ("Second must be between 0 and 59.");
		return false;
	}

	return false;
}

function autosizePanes()
{
	($("#content").height() > $("#sidebar").height() ? $("#sidebar").height( $("#content").height() ) : $("#content").height( $("#sidebar").height() ) );
}
