Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Thanked 0 Times in 0 Posts

    Restaurant Reservation Cutoff time

    Hi Everyone,

    I have been working to try and get this to work with the help of someone but we have been unable to accomplish.

    What I am looking to do is if possible when a person goes to fill out the form is if it is after 4pm they can not make a reservation for that day and that day only. Ideally the date would just change to tomorrow and not even have the option for that day but I didn't know how to even approach that.

    What I then tried to do was make it so it would throw out an error and tell them that if it is after 4pm they have to either call or make a reservation for a different day and the form would not process. I got the error to come up and with the help of someone got the form to not process as well. The main problem I am still having is that it won't let you make a reservation even for the next day or any day if it is after 4pm, even though it should only restrict the current day.

    If anyone can help with the first solution or take a look at the code and let me know where it went wrong I would appreciate it. I am new to javascript and am trying to learn.

    <script language="JavaScript">
    function checkTime(form)
    var curDate = new Date();
    var curHour = curDate.getUTCHours();
    if (curHour > 16)
    alert("Registrations after 4pm for the same day must be called in.");
    return false;
    return true;
    I also have this is the form tag
    <form action="" onsubmit="return checkTime (this)">
    Any help would be appreciated.



  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,564 Times in 2,542 Posts
    You need to post more of your (relevant) code. In particular the HTML regarding the date/time of bookings.

    You need to show the message when the booking date is today and the hour is 4 or more. So you need to check the date as well as the time. I assume that it is impossible to try to make a booking for yesterday.

    UTCHours means Greenwich Mean Time. I assume that your restaurant does not trade internationally! You need the current local time - you do not mention your country so it is hard to be more helpful.

    Lady Astor said to Winston Churchill "If I was married to you, I would put poison in your whisky".
    To which Churchill replied "If I was married to you, I would drink it".


    Posting Permissions

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