function checkEmail( email ) { var intAtPosition = email.indexOf("@"); var intDotPosition = email.indexOf(".", intAtPosition); var intSpacePosition = email.indexOf(" "); if ((intAtPosition < 1) || (intAtPosition > intDotPosition) || (intSpacePosition != -1)) return false; else return true; } function validateForm(form) { //This is the name of the function if (form.Email.value == "") { alert("Please enter your friend(s) email address."); form.Email.focus( ); return false; } if (form.Surname.value == "") { alert("Please enter your name."); form.Surname.focus( ); return false; } if (form.Email1.value == "") { alert("Please enter your email address."); form.Email1.focus( ); return false; } if (!checkEmail(form.Email.value)) { alert("Please enter a valid email address for your friend."); return false; } if (!checkEmail(form.Email1.value)) { alert("Please enter a valid email address for yourself."); return false; } } function checkDate(numberToCheck) { var number = /^(\d)*/; if(number.exec(numberToCheck) && numberToCheck.length == 6) return true; else return false; } function checkPhone(numberToCheck) { var number = /\d\d\d\-\d\d\d\-\d\d\d\d/; if(number.exec(numberToCheck)) return true; else return false; } function checkTextArea(textsize) { document.all.numberofchars.innerHTML = 750-textsize.length; } function checkTextArea2(textsize) { if(textsize.length > 750) { alert('You have exceeded maximum character limits!'); document.contactDole.note.focus(); } } function validator() { var msg=""; var formFail="0"; // set formFail if (document.contactDole.upc.value.length > 10) { msg += "The UPC should be 10 characters max, no hyphen is needed.\n"; formFail="1"; } if (!(document.contactDole.bestByDate.value == null || document.contactDole.bestByDate.value == "")) { if (!checkDate(document.contactDole.bestByDate.value)) { msg += "The Best By date code should be 6 characters and contain no dashes (MMDDYY).\n"; formFail="1"; } } if (!(document.contactDole.purchaseDate.value == null || document.contactDole.purchaseDate.value == "")) { if (!checkDate(document.contactDole.purchaseDate.value)) { msg += "The purchase date should be 6 characters and contain no dashes (MMDDYY).\n"; formFail="1"; } } if (!(document.contactDole.occurrenceDate.value == null || document.contactDole.occurrenceDate.value == "")) { if (!checkDate(document.contactDole.occurrenceDate.value)) { msg += "The occurrence date should be 6 characters and contain no dashes (MMDDYY).\n"; formFail="1"; } } if (!(document.contactDole.homephone.value == null || document.contactDole.homephone.value == "")) { if (!checkPhone(document.contactDole.homephone.value)) { msg += "Your home phone should include your area code (xxx-xxx-xxxx).\n"; formFail="1"; } } if (!(document.contactDole.workphone.value == null || document.contactDole.workphone.value == "")) { if (!checkPhone(document.contactDole.workphone.value)) { msg += "Your work phone should include your area code (xxx-xxx-xxxx).\n"; formFail="1"; } } if (!checkEmail(document.contactDole.from.value)) { msg += "Please enter a valid email address.\n"; formFail="1"; } if (document.contactDole.note.value.length > 750) { msg += "Please shorten your message (750 characters max).\n"; formFail="1"; } // set the focus if (document.contactDole.note.value.length > 750) document.contactDole.note.focus(); if (!checkEmail(document.contactDole.from.value)) document.contactDole.from.focus(); if (!(document.contactDole.workphone.value == null || document.contactDole.workphone.value == "")) { if (!checkPhone(document.contactDole.workphone.value)) document.contactDole.workphone.focus(); } if (!(document.contactDole.homephone.value == null || document.contactDole.homephone.value == "")) { if (!checkPhone(document.contactDole.homephone.value)) document.contactDole.homephone.focus(); } if (!(document.contactDole.occurrenceDate.value == null || document.contactDole.occurrenceDate.value == "")) { if (!checkDate(document.contactDole.occurrenceDate.value)) document.contactDole.occurrenceDate.focus(); } if (!(document.contactDole.purchaseDate.value == null || document.contactDole.purchaseDate.value == "")) { if (!checkDate(document.contactDole.purchaseDate.value)) document.contactDole.purchaseDate.focus(); } if (!(document.contactDole.bestByDate.value == null || document.contactDole.bestByDate.value == "")) { if (!checkDate(document.contactDole.bestByDate.value)) document.contactDole.bestByDate.focus(); } if (document.contactDole.upc.value.length > 10) document.contactDole.upc.focus(); if(formFail=="1") { alert(msg); return (false); } else return (true); } function validateRating() { var radio = document.getElementById('rating').userRank; var check = false; for(i = 0; i