Dear John:
I was hoping you were around somewhere. Most people reserve cars well in advance so anyone entering February at this point will mean 2009 even if they forget to change the year. So I'm just trying to avoid a confusing error message for the user. Here is the entire js file in case that helps: (I inherited it)
Code:
<!--
function goto_URL(object) {
window.location.href = object.options[object.selectedIndex].value;
}
function Pick_Loc() {
Pickup_Loc = document.rental.Pick_Location.value;
document.rental.Drop_Location.value = Pickup_Loc;
}
function Drop_Loc() {
Dropoff_Loc = document.rental.Drop_Location.value;
/* if(Dropoff_Loc == "Maui - Kahului Airport") {
document.rental.Pick_Location.value = Dropoff_Loc;
}
if(Dropoff_Loc == "Maui - Kaanapali") {
document.rental.Pick_Location.value = Dropoff_Loc;
}*/
if(Dropoff_Loc == "Kauai - Lihue Airport") {
document.rental.Pick_Location.value = Dropoff_Loc;
}
}
function Pi_Month() {
Pickup_Month = document.rental.Pick_Month.value;
document.rental.Drop_Month.value = Pickup_Month;
}
function Pi_Day() {
Pickup_Day = document.rental.Pick_Day.value;
document.rental.Drop_Day.value = Pickup_Day;
}
function Pi_Year() {
Pickup_Year = document.rental.Pick_Year.value;
document.rental.Drop_Year.value = Pickup_Year;
}
function validate() {
now = new Date;
day2 = addDays(new Date(),2);
date0 = "12/15/2009";
date1 = document.rental.Pick_Month.value+"/"+document.rental.Pick_Day.value+"/"+document.rental.Pick_Year.value;
date2 = document.rental.Drop_Month.value+"/"+document.rental.Drop_Day.value+"/"+document.rental.Drop_Year.value;
date3 = (now.getMonth()+1)+"/"+now.getDate()+"/"+now.getFullYear();
date4 = (day2.getMonth()+1)+"/"+day2.getDate()+"/"+day2.getFullYear();
date_lim = Date.parse(date0);
date_num1 = Date.parse(date1);
date_num2 = Date.parse(date2);
date_num3 = Date.parse(date3);
date_num4 = Date.parse(date4);
date_diff = date_num2 - date_num1;
date_diff2 = date_num1 - date_num4;
rtime1 = document.rental.Pick_Time.value;
rtime2 = document.rental.Drop_Time.value;
rtime_diff = rtime2 - rtime1;
/* if (document.rental.Pick_Month.value) < (now.getMonth()) {
Pickup_Year = document.rental.Pick_Year.value+1;
document.rental.Drop_Year.value = Pickup_Year;
} */
if (document.rental.Pick_AP[0].checked) {
ptime1 = document.rental.Pick_AP[0].value;
}
if (document.rental.Pick_AP[1].checked) {
ptime1 = document.rental.Pick_AP[1].value;
}
if (document.rental.Drop_AP[0].checked) {
ptime2 = document.rental.Drop_AP[0].value;
}
if (document.rental.Drop_AP[1].checked) {
ptime2 = document.rental.Drop_AP[1].value;
}
if (date_num1 >= date_lim) {
alert("We are sorry, but at this point we are not able to process car pick-up dates beyond December 15, 2009.");
return false;
}
if (date_diff < 0) {
alert("Your rental period needs to be at least 1 day. Please check you pick-up and drop-off date.");
return false;
}
if (date_diff2 < 0) {
alert("Your pick-up date needs to be at least 2 days later than today in order to book thru our system.\nYou can try to call us and we may be able to help you right away 1-866-300-7116. But we won't guarantee it!");
return false;
}
if (date_diff == 0 && rtime_diff < 0) {
if ((ptime1 == 'PM' && ptime2 == 'AM') || (ptime1 == 'AM' && ptime2 == 'AM') || (ptime1 == 'PM' && ptime2 == 'PM')) {
alert("Your drop-off time canīt be earlier than your pick-up time on the same day!\n Please change your pick-up or drop-off date.");
return false;
}
}
Pickup_Loc = document.rental.Pick_Location.value;
Dropoff_Loc = document.rental.Drop_Location.value;
if(Pickup_Loc == "Big Island - Kona Airport" || Pickup_Loc == "Big Island - Hilo Airport") {
if(Dropoff_Loc != "Big Island - Kona Airport" && Dropoff_Loc != "Big Island - Hilo Airport") {
alert("Only Big Island - Kona Airport and Hilo Airport are possible for drop off location.");
return false;
}
}
if(Dropoff_Loc == "Big Island - Kona Airport" || Dropoff_Loc == "Big Island - Hilo Airport") {
if(Pickup_Loc != "Big Island - Kona Airport" && Pickup_Loc != "Big Island - Hilo Airport") {
/* alert("Only Big Island - Kona Airport and Hilo Airport are possible for pick-up location.");*/
alert("You must pick-up and drop-off the car on the same island.");
return false;
}
}
if(Pickup_Loc == "Oahu - Honolulu Airport" || Pickup_Loc == "Oahu - Honolulu City") {
if(Dropoff_Loc != "Oahu - Honolulu Airport" && Dropoff_Loc != "Oahu - Honolulu City") {
alert("Only Oahu - Honolulu Airport and Honolulu City are possible for drop off location.");
return false;
}
}
if(Dropoff_Loc == "Oahu - Honolulu Airport" || Dropoff_Loc == "Oahu - Honolulu City") {
if(Pickup_Loc != "Oahu - Honolulu Airport" && Pickup_Loc != "Oahu - Honolulu City") {
alert("You must pick-up and drop-off the car on the same island.");
return false;
}
}
if(Pickup_Loc == "Maui - Kaanapali" || Pickup_Loc == "Maui - Kahului Airport") {
if(Dropoff_Loc != "Maui - Kaanapali" && Dropoff_Loc != "Maui - Kahului Airport") {
alert("Only Maui - Kaanapali and Kahului Airport are possible for drop off location.");
return false;
}
}
if(Dropoff_Loc == "Maui - Kaanapali" || Dropoff_Loc == "Maui - Kahului Airport") {
if(Pickup_Loc != "Maui - Kaanapali" && Pickup_Loc != "Maui - Kahului Airport") {
alert("You must pick-up and drop-off the car on the same island.");
return false;
}
}
Car_Select = document.rental.Car_Class.value;
if(Car_Select == "PREF") {
alert("Please select the vehicle class before you do the price check.");
return false;
}
}
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
//-->
You can see what happens when you enter (for example) Feb 2008 here:
www.carrentalhawaii.com
Nothing like the real thing to explain better than I can! Thanks for your help.
Bookmarks