var expireDate = new Date(); var year = expireDate.getYear(); year = (year < 1900) ? year + 1900 : year; expireDate.setYear(year + 3); function overAgeRequirement(age) { var targetAgeDate = new Date(); var eighteenYear = targetAgeDate.getFullYear()-18; targetAgeDate.setFullYear(eighteenYear); if (age < targetAgeDate) { return true; }else { return false; } }; function checkDate() { var age = new Date(); age.setMonth(document.subscribeForm.birthmonth[document.subscribeForm.birthmonth.selectedIndex].value-1); age.setDate(document.subscribeForm.birthday[document.subscribeForm.birthday.selectedIndex].value); age.setYear(document.subscribeForm.birthyear[document.subscribeForm.birthyear.selectedIndex].value); if ((document.subscribeForm.birthday[document.subscribeForm.birthday.selectedIndex].value != 0) && (document.subscribeForm.birthmonth[document.subscribeForm.birthmonth.selectedIndex].value !=0) && (document.subscribeForm.birthyear[document.subscribeForm.birthyear.selectedIndex].value != 0)) { if (overAgeRequirement(age)) { return true; } else { return false; } } }; ///////////////////////////////////////////// // Checks for whitespace /////////////////////////////////////////// function isWS(s) { return ((s == null) || (s.length == 0)); }; function validate(status) { var errors = ''; var finalerrors = 'The following fields are required:\n\n'; var f = document.subscribeForm; if (isWS(f.name.value)) errors += ' - Name\n'; if (isWS(f.username.value)) errors += ' - User Name or Screen Name\n'; if (isWS(f.email.value)) errors += ' - Email\n'; if ((f.birthday[f.birthday.selectedIndex].value == 0) || (f.birthmonth[document.subscribeForm.birthmonth.selectedIndex].value ==0) || (f.birthyear[document.subscribeForm.birthyear.selectedIndex].value == 0)) { errors += ' - Birthday\n'; } else { if(checkDate()){ var sAge = f.birthmonth[f.birthmonth.selectedIndex].value; sAge += "/" + f.birthday[f.birthday.selectedIndex].value; sAge += "/" + f.birthyear[f.birthyear.selectedIndex].value; f.birthdate.value = sAge; } else { location.href = f.underageURL.value; return false; } } if (isWS(f.mailaddr.value)) errors += ' - Mailing Address\n'; if(f.optin_one.checked == true){ f.share.value = "Y"; }else{ f.optin_one.value = "N"; errors += ' - You must check "I authorize EA to share my email address..."\n'; } if(status == "accept"){ f.acknowledgment.value = "Y"; } if(status == "decline"){ f.acknowledgment.value = "N"; errors += ' - You must click "I Accept" button" to participate\n'; } if (f.acknowledgment.value == "no_decision") { errors += ' - You must click "I Accept" or "I Decline" button"\n'; } if (errors != '') { finalerrors += errors; alert(finalerrors); return false; } else{ return true; } };