// Global functions function empty_string(what) { if (what == "") return true; else return false; } function valid_zip(what) { if (empty_string(what)) { return false; } var reg = /(^[0-9]{5}$)|(^[0-9]{5}-[0-9]{4}$)/ return reg.test(what); } function valid_email(what) { if (empty_string(what)) { return false; } var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; return reg.test(what); } function check_r_email(email,retype) { if(email==retype) return true; else return false; } // Main validation function function validate() { // Check if any newsletters picked if((!(document.getElementById('alert').checked)) && (!(document.getElementById('newsletter_electronic').checked)) && (!(document.getElementById('newsletter_print').checked))) { alert("Please choose a news item you would like to receive."); document.getElementById('alert').focus(); return false; } // If an electronic news item is picked... if ((document.getElementById('alert').checked) || (document.getElementById('newsletter_electronic').checked)) { // Check first name if(empty_string(document.getElementById('first').value)) { alert("Please enter your first name."); document.getElementById('first').focus(); document.getElementById('first').select(); return false; } // Check last name if(empty_string(document.getElementById('last').value)) { alert("Please enter your last name."); document.getElementById('last').focus(); document.getElementById('last').select(); return false; } // Check email if(!valid_email(document.getElementById('email').value)) { alert("I'm sorry. '" + document.getElementById('email').value + "' is not a valid email address. Please try again."); document.getElementById('email').focus(); document.getElementById('email').select(); return false; } } if (document.getElementById('newsletter_print').checked) { // Check first name if(empty_string(document.getElementById('first').value)) { alert("Please enter your first name."); document.getElementById('first').focus(); document.getElementById('first').select(); return false; } // Check last name if(empty_string(document.getElementById('last').value)) { alert("Please enter your last name."); document.getElementById('last').focus(); document.getElementById('last').select(); return false; } // Check address line 1 if(empty_string(document.getElementById('address1').value)) { alert("Please enter your address."); document.getElementById('address1').focus(); document.getElementById('address1').select(); return false; } // Check city if(empty_string(document.getElementById('city').value)) { alert("Please enter your city."); document.getElementById('city').focus(); document.getElementById('city').select(); return false; } // Check zip code if(!valid_zip(document.getElementById('zip').value)) { alert("I'm sorry. '" + document.getElementById('zip').value + "' is not a valid zip code. Please try again."); document.getElementById('zip').focus(); document.getElementById('zip').select(); return false; } } // All checks passed, return true return true; } function validate_resume() { // Check first name if(empty_string(document.getElementById('first').value)) { alert("Please enter your first name."); document.getElementById('first').focus(); document.getElementById('first').select(); return false; } // Check last name if(empty_string(document.getElementById('last').value)) { alert("Please enter your last name."); document.getElementById('last').focus(); document.getElementById('last').select(); return false; } // Check address line 1 if(empty_string(document.getElementById('address1').value)) { alert("Please enter your address."); document.getElementById('address1').focus(); document.getElementById('address1').select(); return false; } // Check city if(empty_string(document.getElementById('city').value)) { alert("Please enter your city."); document.getElementById('city').focus(); document.getElementById('city').select(); return false; } // Check zip code if(!valid_zip(document.getElementById('zip').value)) { alert("I'm sorry. '" + document.getElementById('zip').value + "' is not a valid zip code. Please try again."); document.getElementById('zip').focus(); document.getElementById('zip').select(); return false; } // Check Home Phone if(empty_string(document.getElementById('hphone').value)) { alert("Please enter your home phone."); document.getElementById('hphone').focus(); document.getElementById('hphone').select(); return false; } // Check Day Phone if(empty_string(document.getElementById('dphone').value)) { alert("Please enter your day phone."); document.getElementById('dphone').focus(); document.getElementById('dphone').select(); return false; } // Check email if(!valid_email(document.getElementById('email').value)) { alert("I'm sorry. '" + document.getElementById('email').value + "' is not a valid email address. Please try again."); document.getElementById('email').focus(); document.getElementById('email').select(); return false; } // Check Salary if(empty_string(document.getElementById('salary').value)) { alert("Please enter your salary requirements."); document.getElementById('salary').focus(); document.getElementById('salary').select(); return false; } // Check Transcript if(empty_string(document.getElementById('file1').value)) { alert("Please enter your transcript."); document.getElementById('file1').focus(); document.getElementById('file1').select(); return false; } // Check Cover Letter if(empty_string(document.getElementById('file2').value)) { alert("Please enter your cover letter."); document.getElementById('file2').focus(); document.getElementById('file2').select(); return false; } // Check Resume if(empty_string(document.getElementById('file3').value)) { alert("Please enter your resume."); document.getElementById('file3').focus(); document.getElementById('file3').select(); return false; } // All checks passed, return true return true; }