Created
March 13, 2014 04:41
-
-
Save DeMarko/9521977 to your computer and use it in GitHub Desktop.
This was the JS that was embedded in the old Access-A-Ride Reservation page. All of the inputs were checked client-side and never server-side
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.myForm.cmbPCA.value = '1';document.myForm.cmbPCA.disabled = false;document.myForm.chkAnimal.checked = false;document.myForm.chkAnimal.disabled = true;document.myForm.cmbXWide.value = 'No'; | |
function cmdSubmit_OnClick() { | |
document.myForm.txtEquipment.value = getSelected(document.myForm.lstEquipment); | |
var myDate = new Date(); | |
myDate.setDate(myDate.getDate()); | |
var myHour = myDate.getHours(); | |
var myTripDate = new Date(document.myForm.cmbTripDate.value); | |
if (1 == 0) | |
alert("Your eligibility has expired. Please call our Eligibility Department at 1-877-337-2017 to schedule a recertification appointment for your Access-A-Ride Service."); | |
else if (document.myForm.txtPickAddress.value == "") | |
alert("Invalid Pickup Address"); | |
else if (document.myForm.txtPickPhone.value == "") | |
alert("Invalid Pickup Phone #"); | |
else if (document.myForm.txtDropAddress.value == "") | |
alert("Invalid Dropoff address"); | |
else if (document.myForm.txtDropPhone.value == "") | |
alert("Invalid Drop Off Phone #"); | |
else if (document.myForm.cmbTripDate.value == "") | |
alert("Invalid Trip Date"); | |
else if (document.myForm.cmbAnchor.value == "") | |
alert("Invalid Request Type"); | |
else if (document.myForm.cmbRequestTimeHH.value == "" || document.myForm.cmbRequestTimeMM.value == "") | |
alert("Invalid Request Time"); | |
else if (myTripDate < myDate || myHour >= 15) | |
alert("Online reservations closes at 3:00 pm. To schedule your trip, please call AAR Reservations at 1-877-337-2017."); | |
else if (document.myForm.cmbAnchor.value == "P" && document.myForm.cmbRequestTimeAMPM.value == "AM" && (document.myForm.cmbRequestTimeHH.value <= "03" || document.myForm.cmbRequestTimeHH.value == "12")) | |
alert("For trip request between 12am and 4am, please call AAR Reservations at 1-877-337-2017. Thank you."); | |
else if (document.myForm.cmbAnchor.value == "A" && document.myForm.cmbRequestTimeAMPM.value == "AM" && (document.myForm.cmbRequestTimeHH.value <= "04" || document.myForm.cmbRequestTimeHH.value == "12")) | |
alert("For trip request between 12am and 4am, please call AAR Reservations at 1-877-337-2017. Thank you."); | |
else { | |
document.myForm.cmbPCA.disabled = false; | |
document.myForm.chkAnimal.disabled = false; | |
document.myForm.submit(); | |
} | |
} | |
function getSelected(myList) { | |
var mySelected = ''; | |
var index = 0; | |
for (var i=0; i < myList.length; i++) { | |
if (myList[i].selected) { | |
if (mySelected.length != 0) { | |
mySelected = mySelected + ','; | |
} | |
mySelected = mySelected + myList[i].value; | |
} | |
} | |
return mySelected; | |
} | |
function cmbAnchor_OnChange() { | |
if (document.myForm.cmbAnchor.value == "A") { | |
document.myForm.cmbServiceWindowID.value = 3; | |
document.myForm.cmbServiceWindowID.disabled = true; | |
} else { | |
document.myForm.cmbServiceWindowID.disabled = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment