Create the calendar-control by calling the "DateInput" function. Parameters are:
DateName - STRING - required; name of the hidden form element to store the selected, formatted date
Required - BOOLEAN - optional; default = FALSE
DateFormat - STRING - optional; default is set as a global variable in the script (MM/DD/YYYY on this page)
DefaultDate - STRING - optional; default = current system date from the client PC
Access via JavaScript:
Custom object for the currently-selected date: DATENAME_Object.picked ...where DATENAME is the name from the 1st parameter of the DateInput function
Properties of the DATENAME_Object.picked object:
date - DATE - Selected date (JavaScript's built-in Date object)
yearValue - NUMERIC - Selected year, as 4 digits
monthIndex - NUMERIC - Selected month (0-11)
monthName - STRING - Full name of selected month
monthShort - STRING - First 3 characters of monthName
day - NUMERIC - Selected day of month (1-31)
dayCount - NUMERIC - Number of days in the month
formatted - STRING - Selected date, in the specified format
Example:
<script>DateInput('someDate', true)</script>
- - -
<script> function validateTheDate() {
var Today = new Date();
if (someDate_Object.picked.date < Today) alert('Cannot select a date in the past.');
else if (someDate_Object.picked.yearValue > 2020) alert('Cannot select dates beyond 2020.');
} </script>
calendarDateInput.js Customizable variables:
Default date format, when none is supplied (3rd parameter) in the call to the "DateInput" function
Number of seconds to wait before the pop-up calendar will disappear
The year at which to interpret 2-digit years in the 20th century, versus the 21st century
Text to display in the 1st month list item when the date isn't required