This script helps to insure the integrity of the date entered in drop-down menus. Dates, such as Feb 31st can't be selected. Today's date is automatically selected.
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
//set todays date Now =newDate(); NowDay =
Now.getDate(); NowMonth =
Now.getMonth(); NowYear =
Now.getYear(); if(NowYear
<2000)
NowYear +=1900;//for Netscape
//function for returning how many days there are in a month including
leap years function
DaysInMonth(WhichMonth,
WhichYear)
{ var
DaysInMonth =31; if(WhichMonth
=="Apr"||
WhichMonth =="Jun"||
WhichMonth =="Sep"||
WhichMonth =="Nov")
DaysInMonth =30; if(WhichMonth
=="Feb"&&(WhichYear/4)!=Math.floor(WhichYear/4))
DaysInMonth =28; if(WhichMonth
=="Feb"&&(WhichYear/4)==Math.floor(WhichYear/4))
DaysInMonth =29; return
DaysInMonth;
}
//function to change the
available days in a months function
ChangeOptionDays(Which)
{ DaysObject =eval("document.Form1."+
Which +"Day"); MonthObject =eval("document.Form1."+
Which +"Month"); YearObject =eval("document.Form1."+
Which +"Year");
Month =
MonthObject[MonthObject.selectedIndex].text; Year =
YearObject[YearObject.selectedIndex].text;
//function to set options to
today function
SetToToday(Which)
{ DaysObject =eval("document.Form1."+
Which +"Day"); MonthObject =eval("document.Form1."+
Which +"Month"); YearObject =eval("document.Form1."+
Which +"Year");