| 
	
 | 
 Posted by Todd Cary on 09/08/05 02:01 
Jordan Miller wrote: 
> writing a parse script is okay, but it will be very difficult to  always  
> ensure they are inputting it correctly. I recommend putting a  popup  
> calendar next to the input field. If the field is automatically   
> populated in this way you will have a much easier time parsing it   
> correctly. I can't recommend a good one offhand, but there are  several  
> that are DHTML and JS only, so that should be a good starting  point for  
> standards compliance. See: 
> http://www.dynarch.com/projects/calendar/ 
> and 
> http://www.google.com/search?q=dhtml+popup+calendar 
>  
> Jordan 
>  
>  
> On Sep 7, 2005, at 5:39 PM, Todd Cary wrote: 
>  
>> I need to check the input of a user to make sure the date is valid   
>> and correctly formatted.  Are there any examples available? 
>> 
>> Here is one solution I created: 
>> 
>>   /* Is date good */ 
>>   function is_date_good($date) { 
>>     if (strtotime($date) == -1) { 
>>       $retval = 0; 
>>     } else { 
>>       if (strpos($date, "/") > 0) { 
>>         $parts = explode("/", $date); 
>>       } elseif (strpos($date, "-") > 0) { 
>>         $parts2 = explode("-", $date); 
>>         $parts[0] = $parts2[1]; 
>>         $parts[1] = $parts2[2]; 
>>         $parts[2] = $parts2[0]; 
>>       } else { 
>>         $parts = explode(".", $date); 
>>       } 
>>       //print_r($parts); 
>>       if (checkdate($parts[0], $parts[1], $parts[2]) ) 
>>         return 1; 
>>       else 
>>         return 0; 
>>     } 
>>     return $retval; 
>>   } 
>> 
>> Is there a simplier solution? 
>> 
>> Many thanks...... 
>> 
>> --  
>> PHP General Mailing List (http://www.php.net/) 
>> To unsubscribe, visit: http://www.php.net/unsub.php 
>> 
>> 
>> 
>> 
My need has to do with claimants for class action lawsuits, so I guess  
having drop downs for months, days and years is one answer. 
 
Todd
 
  
Navigation:
[Reply to this message] 
 |