![Picture of Philip Hewitt Picture of Philip Hewitt](/graphics/unknown.gif)
Philip Hewitt - 2010-01-30 00:57:03
I am attempting to ask for the user to pick their date of birth and then validate they are not older than 123 years and not younger than 18 years.
Here is my time code
-------------------------
$today = date("Y-m-d");
$timestamp = strtotime($today);
$m = date('m',$timestamp);
$d = date('d',$timestamp);
$Y = date('Y',$timestamp);
$oldest_date = mktime(0,0,0,$m,$d,($Y-123));
$youngest_date = mktime(0,0,0,$m,$d,($Y-18));
-------------------------
And here is my AddInput
-------------------------
$form->AddInput(array(
"TYPE"=>"custom",
"ID"=>"dob",
"LABEL"=>"Your <u>B</u>irth Date",
"ACCESSKEY"=>"B",
"CustomClass"=>"form_date_class",
"VALUE"=>$today,
"Format"=>"{month} month / {day} day / {year} year",
"Months"=>array(
"01"=>"January",
"02"=>"February",
"03"=>"March",
"04"=>"April",
"05"=>"May",
"06"=>"June",
"07"=>"July",
"08"=>"August",
"09"=>"September",
"10"=>"October",
"11"=>"November",
"12"=>"December"
),
"ValidationStartDate"=>$oldest_date,
"ValidationStartDateErrorMessage"=>"You cannot be older than the oldest person on record.",
"ValidationEndDate"=>$youngest_date,
"ValidationEndDateErrorMessage"=>"You must be 18 years of age or older to apply.",
));
---------------------------