View Full Version : Restaurant Reservation Cutoff time

06-25-2009, 06:49 PM
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;
{/literal} I also have this is the form tag
<form action="" onsubmit="return checkTime (this)">

Any help would be appreciated.



Philip M
06-25-2009, 07:55 PM
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! :D 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".