PHP Classes

form_date_class Invalid date input

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  form_date_class Invalid date input  >  (Un) Subscribe thread alerts  
Subject:form_date_class Invalid date input
Summary:Getting an error "It was not specified a valid date"
Messages:3
Author:Philip Hewitt
Date:2010-01-30 00:57:03
Update:2010-01-30 18:49:08
 

  1. form_date_class Invalid date input   Reply   Report abuse  
Picture of Philip Hewitt 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.",
));
---------------------------

  2. Re: form_date_class Invalid date input   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-01-30 02:55:50 - In reply to message 1 from Philip Hewitt
Either the VALUE, ValidationStartDate and ValidationEndDate must be in the YYYY-MM-DD format, like for instance '2010-01-30'.

  3. Re: form_date_class Invalid date input   Reply   Report abuse  
Picture of Philip Hewitt Philip Hewitt - 2010-01-30 18:49:08 - In reply to message 2 from Manuel Lemos
Thank you very much, I am sure this information was somewhere in the documentation!