SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Date issue in reservation form
-
Mar 12, 2007, 07:04 #1
- Join Date
- Mar 2003
- Location
- Flanders
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Date issue in reservation form
Hi all,
I use a neat little JS I found on the web to allow users of a site we made to select a date for their arrival and departure in a hotel from a popup calendar. The date they pick appears in formatted text-form in the fields of the form. You can check it out here: http://www.cityhousinggroup.com/rese...ex.php?lang=en
All of this works perfect, but I wonder if there is a way to make sure the date entered in the departure-field is a LATER date than the one selected in the arrival field.
This is the script I use: http://www.rainforestnet.com/datetimepicker.htm
Does anyone have an idea on how to validate the dates as I described? I use a PHP-form with this validation:
PHP Code:<?php
// Create an empty array to hold the error messages.
$arrErrors = array();
// Only validate if the Submit button was clicked.
if (!empty($_POST['Submit'])) {
// Each time there's an error, add an error message to the error array
// using the field name as the key.
if ($_POST['name']=='')
$arrErrors['name'] = 'enter your name';
if (count($arrErrors) == 0) {
// send the form
}
?>ThaVincy | redesigning your image
Twizted Imagebuilding personal and corporate reputation solutions
-
Mar 14, 2007, 04:16 #2
- Join Date
- Mar 2003
- Location
- Flanders
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Please? Does anyone have a suggestion on how to fix this?
ThaVincy | redesigning your image
Twizted Imagebuilding personal and corporate reputation solutions
-
Mar 14, 2007, 04:44 #3
- Join Date
- Oct 2006
- Location
- Kathmandu, Nepal
- Posts
- 4,013
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey man,
its very simple in the case of PHP if i have come to understand your problem. Just convert the dates to the Unix time stamp which is the integer value then you can check it as other normal numbers:
PHP Code:$firstdate = strtotime($_POST['firstdate']);
$seconddate = strtotime($_POST['seconddate']);
if($firstdate > $seconddate){
//trigger the error.
}
Mistakes are proof that you are trying.....
------------------------------------------------------------------------
PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5
Bookmarks