﻿// ANItinLookupFormValidation.js
<!--


function checkRequiredFields(theForm){
    var bSubmitOK = true;        
    var emptyWarn = "";
	var numWarns = 0;

	// First Name
	if (theForm.first.value <= "     ") {
	    displayError('lblValidateFirstName','Required.');
		emptyWarn += "   - First name is required\n";
		numWarns++;
	}

	// Last Name
	if (theForm.last.value <= "     ") {
	    displayError('lblValidateLastName','Required.');
		emptyWarn += "   - Last name is required\n";
		numWarns++;
	}
	
	// Street Address
	if (theForm.street.value <= "     ") {
	    displayError('lblValidateStreet','Required.');
		emptyWarn += "   - Street address is required\n";
		numWarns++;
	}
	
	// City
	if (theForm.city.value <= "     ") {
	    displayError('lblValidateCity','Required.');
		emptyWarn += "   - City is required\n";
		numWarns++;
	}
	
	// Province
	if (theForm.state.value <= "     ") {
	    displayError('lblValidateState','Required.');
		emptyWarn += "   - Province/State is required\n";
		numWarns++;
	}
	
	// Postal Code
	if (theForm.zip.value <= "     ") {
	    displayError('lblValidateZip','Required.');
		emptyWarn += "   - Postal/Zip Code is required\n";
		numWarns++;
	}
	
	// Home Phone
	if (theForm.homefone.value <= "     ") {
	    displayError('lblValidateHomeFone','Required.');
		emptyWarn += "   - Home phone is required\n";
		numWarns++;
	}
	
	// Email Address
	if (theForm.email.value <= "     ") {
	    displayError('lblValidateEmail','Required.');
		emptyWarn += "   - Email address is required\n";
		numWarns++;
	}
	
	// Errors?  Then display them...
	if (numWarns > 0) {
		if (numWarns == 1)
			emptyWarn = "You cannot submit this passenger ID form because\n"
				+ "the following required field is empty:\n\n"
				+ emptyWarn
		else // more than 1 error
			emptyWarn = "You cannot submit this passenger ID form because\n"
				+ "the following required fields are empty:\n\n"
				+ emptyWarn

		alert(emptyWarn);
		bSubmitOK = false;
	}
        
    return bSubmitOK;
}

function hideErrorLabels(){
    hideError('lblValidateFirstName');
    hideError('lblValidateLastName');
    hideError('lblValidateStreet');
    hideError('lblValidateCity');
    hideError('lblValidateState');
    hideError('lblValidateZip');
    hideError('lblValidateHomeFone');
    hideError('lblValidateEmail');
}


function doSubmit(){
    var bSubmitOK = true;
    
    hideErrorLabels();
    bSubmitOK = checkRequiredFields(document.forms['frmPAXID']);

    if (bSubmitOK == true) {
        
		 //submit the form
		document.forms['frmPAXID'].target = "_top";     // _blank, _self, _parent, _top
		document.forms['frmPAXID'].submit();
	}
}

//-->

