Displaying number of days in form field depending on month
<p>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.</p>

<pre><code>&lt;?php
$monthOptions = '';
$dayOptions = '';
$yearOptions = '';

for($month=1; $month&lt;=12; $month++){
    $monthName = date("M", mktime(0, 0, 0, $month));
    $monthOptions .= "&lt;option value=\"$month\"&gt;$monthName&lt;/option&gt;\n";
}
for($day=1; $day&lt;=31; $day++){
    $dayOptions .= "&lt;option value=\"$day\"&gt;$day&lt;/option&gt;\n";
}
for($year=1900; $year&lt;=2010; $year++){
    $yearOptions .= "&lt;option value=\"$year\"&gt;$year&lt;/option&gt;\n";
}
?&gt;
&lt;html&gt;

&lt;body&gt;
Select date:&lt;br /&gt;
&lt;select name="month" id="month" &gt;
&lt;?php echo $monthOptions; ?&gt;
&lt;/select&gt;

&lt;select name="day" id="day"&gt;
&lt;?php echo $dayOptions; ?&gt;
&lt;/select&gt;

&lt;select name="year" id="year" &gt;
&lt;?php echo $yearOptions; ?&gt;
&lt;/select&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
