SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    reputation consultant ThaVincy's Avatar
    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

  2. #2
    reputation consultant ThaVincy's Avatar
    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

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    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.

    Does this help?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •