On Tue, 2009-02-17 at 17:16 -0500, Paul M Foster wrote:
> On Tue, Feb 17, 2009 at 03:55:16PM -0600, Terion Miller wrote:
> > What are your suggestions folks on how to go about setting a date on a form
> > so that a user can not set a start date prior to the current days date?
> > I've been looking around php.net but is it a javascript thing in the
> > validation I should be dealing with, basically as it is I have a form and a
> > user can select a start date, but they should not be able to select a date
> > that is past, currently the start date form is a drop down (a very long drop
> > down) I would like to use one of those nifty calendar popups but am not sure
> > (aka..wasn't able to figure out) how to send the date to the db fields as
> > they are...
> > guidance on this would be great ..how would you do it?
> > thanks guys and gals
> > Terion
> Broadly, you're either going to have to limit their choices going in to
> the form (limit the choices in the drop-down box), or validate it
> afterwards and generate an error message if it's wrong.
> I've never seen one of those calendar gizmos that wasn't Javascript,
> except maybe for Ashley's (mentioned in another thread). And even at
> that, a PHP one won't be selectable the way you want unless you put
> radio buttons next to all the dates. And after all that, you'd still
> have to do some pre-processing of it to limit selections to current date
> and later.
> Paul
> -- 
> Paul M. Foster
What about just accepting any date in to the system, and defaulting to
the current date if any numptys/users try to set one before?

Do something maybe like this (untested)

$userDate = strtotime($_REQUEST['date']);
$startDate = ($userDate < time())?time():$userDate;

>From there, you can use the timestamp how you wish.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to