// Required on load functions window.onload = function() { var dateInit = document.ff_fs.dateCheck.value; // Only set current date on initial page request when date has not already been initialised if (dateInit == "init_no") { initDate(document.ff_fs, document.ff_fs.departureMonth, document.ff_fs.departureDay); document.ff_fs.dateCheck.value = "init_yes"; } preloadImgs('/content/images/uk/modules/common/error2.gif', 13, 15, '/content/images/uk/modules/common/error3.gif', 15, 18); } // VALIDATE FORM function validateForm() { var errHeadSet = false; var isValid = true; var orig = document.forms["ff_fs"]["origin"]; var dest = document.forms["ff_fs"]["destination"]; var tripType = document.forms["ff_fs"]["tripType"] var numAdt = document.forms["ff_fs"]["numAdultPassengers"]; var numChd = document.forms["ff_fs"]["numChildPassengers"]; var depMonth = document.forms["ff_fs"]["departureMonth"]; var depDay = document.forms["ff_fs"]["departureDay"]; var depTime = document.forms["ff_fs"]["departureTime"]; var retMonth = document.forms["ff_fs"]["returnMonth"]; var retDay = document.forms["ff_fs"]["returnDay"]; var retTime = document.forms["ff_fs"]["returnTime"]; // Checks if dropdown of free search is being used if (document.forms["ff_fs"]["originFreeSearch"].value == "true") { orig = orig.value; } else { orig = orig.options[orig.selectedIndex].value; } if (document.forms["ff_fs"]["destinationFreeSearch"].value == "true") { dest = dest.value; } else { dest = dest.options[dest.selectedIndex].value; } /**** * Fix for defect 2560 - Added 09/28/09 * Regex for permitted characters, anything outside of this range will be rejected * Permitted characters = Extended latin chars and a-z. Case is ignored **/ var rePcr = /[^a-z\s\u00e0-\u00ef\u00f1-\u00f6\u00f8-\u00fc]/i; // End of defect 2560 fix // Calculate total passenger count var ttlPaxCount = parseInt(numAdt.options[numAdt.selectedIndex].value) + parseInt(numChd.options[numChd.selectedIndex].value); // Clear any previous error messages before validating form fsError.clearError('error', 'span'); fsError.clearError('ffSf','label'); if (orig == "" || rePcr.test(orig)) { if (!errHeadSet) { fsError.setMessageHeader('error', 'The following error(s) occured', 'SFError', '/content/images/uk/modules/common/error3.gif'); errHeadSet = true; } fsError.setMessage('error', 'Please provide us with a departure city and try again.'); fsError.setAlert('from', '/content/images/uk/modules/common/error2.gif'); isValid = false; } if (dest == "" || rePcr.test(dest)) { if (!errHeadSet) { fsError.setMessageHeader('error', 'The following error(s) occured', 'SFError', '/content/images/uk/modules/common/error3.gif'); errHeadSet = true; } fsError.setMessage('error', 'Please provide us with a return city and try again.'); fsError.setAlert('to', '/content/images/uk/modules/common/error2.gif'); isValid = false; } if (ttlPaxCount > 6) { if (!errHeadSet) { fsError.setMessageHeader('error', 'The following error(s) occured', 'SFError', '/content/images/uk/modules/common/error3.gif'); errHeadSet = true; } fsError.setMessage('error', 'The maximum total number of passengers you can book online is six.'); fsError.setAlert('adult', '/content/images/uk/modules/common/error2.gif'); isValid = false; } // Check if outbound date is within permitted range of 329 days if (!checkDateRange(document.ff_fs.departureMonth.options[document.ff_fs.departureMonth.selectedIndex].value, document.ff_fs.departureDay.options[document.ff_fs.departureDay.selectedIndex].value, 0, 0, 0, 329, true)) { if (!errHeadSet) { fsError.setMessageHeader('error', 'The following error(s) occured', 'SFError', '/content/images/uk/modules/common/error3.gif'); errHeadSet = true; } fsError.setMessage('error', 'We can only display departing flights up to 329 days from today.'); fsError.setAlert('depDate', '/content/images/uk/modules/common/error2.gif'); if (tripType.value != "oneWay") { fsError.setMessage('error', 'We can only display flights returning within the next 329 days.'); fsError.setAlert('retDateLbl', '/content/images/uk/modules/common/error2.gif'); } isValid = false; } // If trip type selected is not one-way check if return date is within permitted range of 329 days & in chronological order if (checkDateRange(document.ff_fs.departureMonth.options[document.ff_fs.departureMonth.selectedIndex].value, document.ff_fs.departureDay.options[document.ff_fs.departureDay.selectedIndex].value, 0, 0, 0, 329, true)) { var obYear = getYear(document.ff_fs.departureMonth.options[document.ff_fs.departureMonth.selectedIndex].value, document.ff_fs.departureDay.options[document.ff_fs.departureDay.selectedIndex].value); if (tripType.value != "oneWay") { if (!checkDateRange(document.ff_fs.returnMonth.options[document.ff_fs.returnMonth.selectedIndex].value, document.ff_fs.returnDay.options[document.ff_fs.returnDay.selectedIndex].value, obYear, document.ff_fs.departureMonth.options[document.ff_fs.departureMonth.selectedIndex].value, document.ff_fs.departureDay.options[document.ff_fs.departureDay.selectedIndex].value, 329, false)) { if (!errHeadSet) { fsError.setMessageHeader('error', 'The following error(s) occured', 'SFError', '/content/images/uk/modules/common/error3.gif'); errHeadSet = true; } fsError.setMessage('error', 'We can only display flights returning within the next 329 days.'); fsError.setAlert('retDateLbl', '/content/images/uk/modules/common/error2.gif'); isValid = false; } } } // [ER request 00001 18/04/08] Do state table lookup if more than 3 letter value if (orig.length > 3) { orig = checkIfState(orig); } if (dest.length > 3) { dest = checkIfState(dest); } // End of ER 00001 return isValid; }