Hi All,
I’m trying to build the “checkdate” function into this piece of code but it seems to output the “invalid date” text on the page all the time (before I’ve even submitted the form) - Can someone tell me the right place to put it and the correct syntax to use please?
Here is the code that is used to build the form:
function duedate_datechooser($name,$value="")
{
$months=array('','January','February','March','April','May','June','July','August',
'September','October','November','December');
if(empty($value)) $value=date("Y-m-d");
$parts=explode("-",$value);
$day=$parts[2]+0;
$month=$parts[1]+0;
$year=$parts[0];
$chooser="";
$chooser.="<select name=".$name."day>";
for($i=1;$i<=31;$i++)
{
if($i==$day) $selected='selected';
else $selected='';
$chooser.="<option $selected>$i</option>";
}
$chooser.="</select> / ";
$chooser.="<select name=".$name."month>";
for($i=1;$i<=12;$i++)
{
if($i==$month) $selected='selected';
else $selected='';
$chooser.="<option $selected value=$i>$months[$i]</option>";
}
$chooser.="</select> / ";
$chooser.="<select name=".$name."year>";
for($i=(date("Y")-1);$i<=2050;$i++)
{
if($i==$year) $selected='selected';
else $selected='';
$chooser.="<option $selected>$i</option>";
}
$chooser.="</select> ";
return $chooser;
}
I need to check the date is valid when the form is submitted.
Thanks,