I want to validate the basic date format in the form. The date has three fields in form, Month, Day and Year. I want to make it so that, if a month January, March, May, July, August, October or December is selected then it should display 31 days in the day field. If february is selected, then it should display 28 days, otherwise 30 days. Also, If someone selects day before the month and then selects the month, then it should reset the selected day to 1. Here's my form code. I shall be very thankful for any help.
<?php
$monthOptions = '';
$dayOptions = '';
$yearOptions = '';
for($month=1; $month<=12; $month++){
$monthName = date("M", mktime(0, 0, 0, $month));
$monthOptions .= "<option value=\"$month\">$monthName</option>\n";
}
for($day=1; $day<=31; $day++){
$dayOptions .= "<option value=\"$day\">$day</option>\n";
}
for($year=1900; $year<=2010; $year++){
$yearOptions .= "<option value=\"$year\">$year</option>\n";
}
?>
<html>
<body>
Select date:<br />
<select name="month" id="month" >
<?php echo $monthOptions; ?>
</select>
<select name="day" id="day">
<?php echo $dayOptions; ?>
</select>
<select name="year" id="year" >
<?php echo $yearOptions; ?>
</select>
</body>
</html>