Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

booking form date/time custom rule

Status
Not open for further replies.

lhcjavascript

IS-IT--Management
Jul 1, 2010
1
0
0
GB
Hello everyone, hope you are well.

I would like to add 3 more 'pickup time' rules to my form to co-incide with the rules already in place. i have no idea how to apply these because the code is too advanced for me so any help would be much appreciated.

1. if the user chooses a pickup time between 00:00 and 04:00 - alert ("We do not operate within those hours")
basically we are a cab company and we do not offer cab services between midnight and 4am)


2. if the user chooses a pickup time that is within 6 hours of the current time - alert ("Please call us to confirm this booking")
this rule is here because we do not want people booking a car at such short notice without telling us directly


3. if the current time is between 21:00 and 09:00 and the user chooses a pickup time that is within 24 hours of the current time - alert ("You must book atleast 24 hours in advance")
our office is closed between midnight and 4am so if people book late at night or early morning we want atleast 24 hours notice


my code is below, if anyone can assist me i can upload it immediately and test. thanks

Code:
<!-- $Header: /Projects/Taxi/WebBooker/WJBasp.NV/includes/bookstep1.checkform.inc 5     11/09/08 18:59 David.g $ -->
<%
var d = new Date;
%>
<script language="Javascript">
var serverTimeLead      = 0;

function OnLoad()
{
    var now        = new Date();
    serverTimeLead = (now.getTimezoneOffset()) - (<% = d.getTimezoneOffset() %>);
    serverTimeLead *= 60000.0;

    if (serverTimeLead) $("PickupTimeLegend").innerHTML = "UK Local:&nbsp;&nbsp;";

    <% if (!Session("isIE")) { %>
    initCal(); 
    <% } %>

    if (document.mainForm.PickupTime.value == "")
    {
       now.setTime(now.getTime() + <% = (leadTimeTicks > 0) ? leadTimeTicks : 0 %> + (serverTimeLead));
       formDateTime(now, document.mainForm.PickupTime, document.mainForm.PickupDate);
    }
}

function CheckForm(f)
{
   var puTime = new Date();
   var e = makeDateTime(f.PickupTime, f.PickupDate, puTime);
   
   if (e == 1)
   {
      alert("Pickup Time is invalid\n\nCorrect value should be like 12:30 or 23:59");
      f.PickupTime.focus();
      return false;
   }
   else if (e == 2)
   {
      alert("Pickup Date is invalid");
      return false;
   }
   
   var now = new Date();
   now.setTime(now.getTime() + (serverTimeLead));

   if ((now.getTime() - puTime.getTime()) > (5 * 60 * 1000))
   {
      alert("Pickup time can't be in the past");
      f.PickupTime.focus();
      return false;
   }

   if ((now.getTime() - puTime.getTime()) > ((5 * 60 * 1000) - <% =leadTimeTicks %>))
   {
      alert("You must book at least <% = Session("User").LeadTimeFormatted %> in advance");
      f.PickupTime.focus();
      return false;
   }


<%
  }
%>

   f.PickupDateTime.value = String(puTime.getTime() - serverTimeLead);

   return true;
}
</script>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top