// ActionScript Document //===================== // Check full Name //===================== function checkfullName(strng) { var error = ""; if (strng == "") { error = "Please type your full name.\n" } return error; } //============================================================ // phone number - strip out delimiters and check for 10 digits //============================================================ function checkPhone (strng) { var error = ""; if (strng == "") { error = "Please provide a phone number.\n"; } else { var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters if (isNaN(parseInt(stripped))) { error = "The phone number contains illegal characters."; } if (!(stripped.length == 10)) { error = "The phone number is the wrong length. Make sure you included an area code.\n"; } } return error; } //============== // email //============== function checkEmail (strng) { var error = ""; if (strng == "") { error = "Please provide an email address.\n"; } else { var emailFilter=/^.+@.+\..{2,3}$/; if (!(emailFilter.test(strng))) { error = "Please enter a valid email address.\n"; } else { //test email for illegal characters var illegalChars= "/[\(\)\<\>\,\;\:\\\"\[\]]/" if (strng.match(illegalChars)) { error = "The email address contains illegal characters.\n"; } } } return error; } //===================== // Check Arrival Month //===================== function checkArrMonth(choice) { var error = ""; if (choice == 0) { error = "Please select your arrival month.\n"; } return error; } //===================== // Check Arrival Day //===================== function checkArrDay(choice) { var error = ""; if (choice == 0) { error = "Please select your arrival day.\n"; } return error; } //===================== // Check Arrival Year //===================== function checkArrYear(choice) { var error = ""; if (choice == 0) { error = "Please select your arrival year.\n"; } return error; } //======================== // Check Number of Nights //======================== function checkNights(choice) { var error = ""; if (choice == 0) { error = "Please select a number of nights.\n"; } return error; } //======================= // Check number of Guest //======================= function checkNoGuests(choice) { var error = ""; if (choice == 0) { error = "Please select a number of guests.\n"; } return error; } function validation(theForm) { var why = ""; why += checkfullName(theForm.fullName.value); why += checkPhone(theForm.phone.value); why += checkEmail(theForm.emailFrom.value); why += checkArrMonth(theForm.arrMonth.value); why += checkArrDay(theForm.arrDay.value); why += checkArrYear(theForm.arrYear.value); why += checkNights(theForm.nights.value); why += checkNoGuests(theForm.noguests.value); if (why != "") { alert(why); return false; } return true; }