Hi I am just new to programing and I am working on an scheduler for meetings. I have 2 textbox by default
textbox1 -> $date_from
textbox2->$date_to
My problem is I want to have an error checking or invalid input checker when the user clicks the submit button. For example when the user enter a previous date which must be invalid and the value of the $date_from is ahead of $date_to.
Example:
$date_from -> 02-Feb-2001
$date_to -> 14-Feb-2001 //must be invalid because its a previous date
$date_from -> 1-Mar-2009
$date_to -> 18-Feb-2009 //must be invalid because $date_from is ahead of $date_to
Any idea on how can I create error checking and display the error?
Thanks
help with previous dates
Moderator: General Moderators
Re: help with previous dates
Change the variables to time and compare.. here is a sample code
Code: Select all
$date_from = '04-Feb-2009';
$date_to = '08-Feb-2009';
$mydate_from = strtotime($date_from);
$mydate_to = strtotime($date_to);
if($mydate_from>$mydate_to)
{
//the from date is earlier than the to date
//show error or redirect from here
}
else
{
// the input given is correct. processing code to be got here
}
-
greedyisg00d
- Forum Commoner
- Posts: 42
- Joined: Thu Feb 12, 2009 2:48 am
Re: help with previous dates
Thanks. how about if the dates that are inputted are previous dates for example feb-14-1992 which is invalid? Since the scheduler must set dates from current to future dates only.
Re: help with previous dates
do you mean you want to check if the given date is future date or not right??