how to validate drop dowan calendar in php
Posted: Tue Sep 29, 2009 6:52 am
Hello friends,
in my form i am having 3 date fields......i got this date function
<?php
//This function makes 3 pulldown menus for the months, days, and years.
function make_calendar_pulldowns2($m2 = NULL, $d2 = NULL, $y2 = NULL)
{
//Make the months array.
$months2 = array (1 => 'January','February','March','April','May','June','July','August','September','October','November','December');
//Make the months into a pulldowm.
echo '<select name="month2">';
foreach ($months2 as $key => $value)
{
echo "<option value=\"$key\"";
if ($key == $m2);
{
//Preselect.
echo ' selected="selected"';
}
echo ">$value</option>\n";
}
echo '</select>';
//Make the days pull-down menu.
echo '<select name="day2">';
for ($day2 = 1; $day2 <= 31; $day2++)
{
echo "<option value=\"$day2\"";
if ($day2 == $d2)
{
//Preselect.
echo ' selected="selected"';
}
echo ">$day2</option>\n";
}
echo '</select>';
//Make the years pull-down menu.
echo '<select name="year2">';
for ($year2 = 1950; $year2 <= 2022;
$year2++)
{
echo "<option value=\"$year2\"";
if ($year2 == $y2)
{
//Preselect.
echo ' selected="selected"';
}
echo ">$year2</option>\n";
}
echo '</select>';
}//End of Function Definition
//Get today's date and call the function.
$dates2 = getdate();
$date_birth= make_calendar_pulldowns2($dates2['mon'],$dates2['mday'],$dates2['year']);
$date2= make_calendar_pulldowns2($dates2['mon'],$dates2['mday'],$dates2['year']);
?>
can any body tell me how to validate (leap year and all)...........
please tell me how can i use it....thanks
in my form i am having 3 date fields......i got this date function
<?php
//This function makes 3 pulldown menus for the months, days, and years.
function make_calendar_pulldowns2($m2 = NULL, $d2 = NULL, $y2 = NULL)
{
//Make the months array.
$months2 = array (1 => 'January','February','March','April','May','June','July','August','September','October','November','December');
//Make the months into a pulldowm.
echo '<select name="month2">';
foreach ($months2 as $key => $value)
{
echo "<option value=\"$key\"";
if ($key == $m2);
{
//Preselect.
echo ' selected="selected"';
}
echo ">$value</option>\n";
}
echo '</select>';
//Make the days pull-down menu.
echo '<select name="day2">';
for ($day2 = 1; $day2 <= 31; $day2++)
{
echo "<option value=\"$day2\"";
if ($day2 == $d2)
{
//Preselect.
echo ' selected="selected"';
}
echo ">$day2</option>\n";
}
echo '</select>';
//Make the years pull-down menu.
echo '<select name="year2">';
for ($year2 = 1950; $year2 <= 2022;
$year2++)
{
echo "<option value=\"$year2\"";
if ($year2 == $y2)
{
//Preselect.
echo ' selected="selected"';
}
echo ">$year2</option>\n";
}
echo '</select>';
}//End of Function Definition
//Get today's date and call the function.
$dates2 = getdate();
$date_birth= make_calendar_pulldowns2($dates2['mon'],$dates2['mday'],$dates2['year']);
$date2= make_calendar_pulldowns2($dates2['mon'],$dates2['mday'],$dates2['year']);
?>
can any body tell me how to validate (leap year and all)...........
please tell me how can i use it....thanks