Full version: jsB@nk » Time » Clock » Date Selection Form script
URL: https://www.javascriptbank.com/date-selection-form-script.html
This handy script lets you auto-generate the day and year in a dropdown selection as well as validate the date. Add it to your pages that require date validation.
Full version: jsB@nk » Time » Clock » Date Selection Form script
URL: https://www.javascriptbank.com/date-selection-form-script.html
<Script Language="JavaScript">function populate(inForm){var temp=0;var today= new Date();var day= today.getDate();var month= today.getMonth();var year= today.getFullYear();t2= prompt("Enter the number of years to fetch",1);for (var i=0; i <31 ; i++){var x= String(i+1);inForm.day.options[i] = new Option(x,x);}for (var i=0; i <31 ; i++){var d=0;d=inForm.day.options[i].value;if(d=day){inForm.day.options[i].selected=true;break;}}for (var i=0,j=year; i <t2 ; i++, j--){var y= String(j);inForm.year.options[i] = new Option(y,y);}for(var i=0;i<12;i++){if(i=month){inForm.month.options[i].selected=true;break;}}}function populate2(inForm2){var t3=0;if(inForm2.month.options[1].selected)t3=28;else if(inForm2.month.options[8].selected||inForm2.month.options[3].selected||inForm2.month.options[5].selected||inForm2.month.options[10].selected)t3=30;elset3=31;for(i=0;i<31;i++){inForm2.day.options[i]=null;}for (var i=0; i <t3 ; i++){var x= String(i+1);inForm2.day.options[i] = new Option(x);}}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<BODY onLoad=populate(form1)><FORM NAME="form1"><p><b>Day</b> <SELECT NAME="day"></SELECT> <b>Month</b> <SELECT NAME="month" onChange = populate2(form1)><Option value=0>January</Option><Option value=1>February</Option><Option value=2>March</Option><Option value=3>April</Option><Option value=4>May</Option><Option value=5>June</Option><Option value=6>July</Option><Option value=7>August</Option><Option value=8>September</Option><Option value=9>October</Option><Option value=10>November</Option><Option value=11>December</Option></SELECT> <b>Year</b><SELECT NAME="year"></SELECT></FORM></body><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->