/*-- SimplicityPlan.js for simplicity plan. jwl 08.19.2009 --*/ /*-- START - for forms page - added by jwl 08.25.2009 --*/ //will be used to check fields and submit forms function submit_login(myForm) { //alert ("myForm.rememberme.checked= *" + myForm.rememberme.checked + "*") //alert ("myForm.VerLoginID.value= *" + myForm.VerLoginID.value + "*") //alert ("myForm.VerPassword.value= *" + myForm.VerPassword.value + "*") //5 years from now var myDate = new Date(); myDate.setFullYear(myDate.getFullYear() + 5); //alert(myDate); if (myForm.rememberme.checked) { SetCookie ("loginID", myForm.VerLoginID.value, myDate, "/") SetCookie ("loginPass", myForm.VerPassword.value, myDate, "/") } else { SetCookie ("loginID", "", myDate, "/") SetCookie ("loginPass", "", myDate, "/") } myForm.submit(); return true; //return false; } //function submit_form(myForm) function submit_form(myForm) { //alert ("In submit_form") //alert ("In Form Name= *" + myForm.LoginID.value + "*") myForm.submit(); return true; //return false; } /*-- END - for forms page - added by jwl 08.25.2009 --*/ function SetCookie(name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } //function submit_form(myForm) function sp_submit_form(myForm,nextPage) { //these are default values in the text boxes that need to be cleaned up before submitting. Will need to add spanish values //each value needs to stop and start with a pipe var defaultValues = "|First Name|Primer Nombre|Middle Name|Last Name|Apellido|Suffix|City/Town|State/Country|Maiden/Last Name|Maiden Name|Document Location|from Bible or other literature|military, lodge, society or fraternal|Description of cemetery property (if owned)|Song Artist|Song Title|" var txt_error = "" //alert ("In sp_submit_form - nextPage = *" + nextPage + "*") //alert ("In sp_submit_form - BEFORE myForm.next_page.value = *" + myForm.next_page.value + "*") if (nextPage!= '') { if (myForm.next_page) { myForm.next_page.value = nextPage } } //alert ("In sp_submit_form - myForm.required_fields = *" + myForm.required_fields + "*") if (myForm.required_fields) { txt_error_UnspecifiedRequired = "- fill in all the required fields.\n"; txt_error_UnspecifiedRadioSelectRequired = "- select an option.\n"; txt_error_EmailRequired = "- EMAIL ADDRESS is required\n"; txt_error_EmailFormatWrong = "- EMAIL ADDRESS format is not correct\n"; txt_error_FirstNameRequired = "- FIRST NAME is required\n"; txt_error_LastNameRequired = "- LAST NAME is required\n"; txt_error_AddressRequired = "- ADDRESS is required\n"; txt_error_CityRequired = "- CITY is required\n"; txt_error_StateRequired = "- STATE is required\n"; txt_error_ZipCodeRequired = "- ZIPCODE is required\n"; txt_error_PasswordRequired = "- PASSWORD is required\n"; //txt_error_ConfirmTermsUnchecked = "You must agree to the terms of use before continuing.\n\nThank You." txt_error_ConfirmTermsUnchecked = "To proceed, you must agree to our Terms of Use. Please return to the page, and confirm that you’ve read our terms of use by checking the box to continue." txt_error_DayPhoneWrongLength = "The Daytime Phone fields must contain a total of 10 digits." txt_error_NightPhoneWrongLength = "The Nighttime Phone fields must contain a total of 10 digits." var required_fields = myForm.required_fields.value; //alert ("In Form required_fields= *" + required_fields + "*"); var my_RequiredArray = required_fields.split("|"); focusSet = false; unspecified_Written = false; email_Written = false; emailFormat_Written = false; lName_Written = false; fName_Written = false; add_Written = false; city_Written = false; state_Written = false; zCode_Written = false; isPWOK = false; for (var i=0; i< my_RequiredArray.length; i++) { //alert ("In Form required_fields= *" + required_fields + "*") //run through the form to see if there is an element of that name //if there is check the value //if its blank, run through the the if statements to show the text and run the focus my_FieldName = my_RequiredArray[i]; //alert ("In Form my_FieldName= *" + my_FieldName + "*") my_FormValue = ""; my_FormType = ""; foundField = false; fieldNum = -1; for(x = 0; x < myForm.elements.length; x++) { if (myForm.elements[x].name == my_FieldName) { foundField = true; my_FormValue = myForm.elements[x].value; my_FormType = myForm.elements[x].type; fieldNum = x; break; } } if (foundField) { //alert ("In Form my_FieldName= *" + my_FieldName + "*") //alert ("In Form my_FormType= *" + my_FormType + "*") //alert ("In Form fieldNum= *" + fieldNum + "*") if (my_FormType=="radio") { //is a value selected? my_Option = -1; var myRadio = myForm.elements[my_FieldName]; //alert ("myRadio = *" + myRadio + "*") //alert ("myForm.elementName[" + my_FieldName + "].length= *" + myForm.elementName[my_FieldName].length + "*") //alert ("myRadio.length= *" + myRadio.length + "*") for (ct_Radio = myRadio.length - 1; ct_Radio > -1; ct_Radio--) { //alert ("myRadio[" + ct_Radio + "].checked = *" + myRadio[ct_Radio].checked + "*") if (myRadio[ct_Radio].checked) { my_Option = ct_Radio; ct_Radio = -1; } } if (my_Option == -1) { //alert("You must select a radio button"); txt_error += txt_error_UnspecifiedRadioSelectRequired; //return false; } else { //alert ("myRadio[" + my_Option + "]= *" + myRadio[my_Option].value + "*") //alert ("my_FieldName= *" + my_FieldName + "*") if (my_FieldName=="useepriselogin") { if (myRadio[my_Option].value == "yes") { if ((myForm.email)&&(myForm.old_email)) { myForm.email.value = myForm.old_email.value } } else { //is email filled out? if (myForm.email) { var myFormEmailVal = myForm.email.value if (myFormEmailVal=="") { txt_error += txt_error_EmailRequired; } else if ((myFormEmailVal.indexOf("@")==-1) || (myFormEmailVal.indexOf(".")==-1)) { txt_error += txt_error_EmailFormatWrong; } } // if email field exists } } // if field is useepriselogin } } else if (my_FormType=="checkbox") { //This is for the join form - only use this error and return false if (my_FieldName=="confirm_terms") { if (!myForm.elements[my_FieldName].checked) { txt_error += txt_error_ConfirmTermsUnchecked; myForm.elements[fieldNum].focus(); alert(txt_error) return false; } } } else { //alert ("In Form my_FormValue= *" + my_FormValue + "*") //alert ("In Form my_FieldName= *" + my_FieldName + "*") //clean up credit card number if there are spaces or dashes if (my_FieldName=="cc_number") { temp_CC_val = myForm.elements[fieldNum].value temp_CC_val = temp_CC_val.replace(/ /g,'') temp_CC_val = temp_CC_val.replace(/-/g,'') myForm.elements[fieldNum].value = temp_CC_val } switch (my_FieldName) { case "email": case "yourEmail": case "friendEmail": if (my_FormValue == "") { if (!email_Written) { txt_error += txt_error_EmailRequired; email_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } else if ((my_FormValue.indexOf("@")==-1) || (my_FormValue.indexOf(".")==-1)) { if (!emailFormat_Written) { txt_error += txt_error_EmailFormatWrong; emailFormat_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "first_name": case "billing_first_name": case "cc_first_name": case "mailing_first_name": if ((my_FormValue == "")||(my_FormValue == "First Name")||(my_FormValue == "Primer Nombre")) { if (!fName_Written) { txt_error += txt_error_FirstNameRequired; fName_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "last_name": case "billing_last_name": case "cc_last_name": case "mailing_last_name": if ((my_FormValue == "")||(my_FormValue == "Last Name")||(my_FormValue == "Apellido")) { if (!lName_Written) { txt_error += txt_error_LastNameRequired; lName_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "mailing_address_1": if (my_FormValue == "") { if (!add_Written) { txt_error += txt_error_AddressRequired; add_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "mailing_city": if (my_FormValue == "") { if (!city_Written) { txt_error += txt_error_CityRequired; city_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "mailing_state": if (my_FormValue == "") { if (!state_Written) { txt_error += txt_error_StateRequired; state_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "zipcode": case "mailing_zip": if ((my_FormValue == "")||(my_FormValue == "Enter Your Zip Code")||(my_FormValue == "SPANISH Enter Your Zip Code")) { if (!zCode_Written) { txt_error += txt_error_ZipCodeRequired; zCode_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "password": if (my_FormValue == "") { txt_error += txt_error_PasswordRequired; if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } passwordMessage = passwordCheck(myForm.password.value,myForm.password_confirm.value) if (passwordMessage!='') { txt_error += passwordMessage; if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; case "VerNewPasswd": if (my_FormValue == "") { txt_error += txt_error_PasswordRequired; if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } passwordMessage = passwordCheck(myForm.VerNewPasswd.value,myForm.VerNewPasswdConfirm.value) if (passwordMessage!='') { txt_error += passwordMessage; if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; default: if (my_FormValue == "") { //txt_error = txt_error + txt_error_Unspecified if (!unspecified_Written) { txt_error += txt_error_UnspecifiedRequired; unspecified_Written = true; } if (!focusSet) { myForm.elements[fieldNum].focus(); focusSet = true; } } break; }//End switch } // test type } } } //alert ("In sp_submit_form - AFTER myForm.next_page.value = *" + myForm.next_page.value + "*") //alert ("In submit_form") //alert ("In Form Name= *" + myForm.LoginID.value + "*") //Special check for "other" fields for radio buttons and checkboxes - if other_specify is the radio/checkbox value - will assign value to what is in the text box names "other_[fieldname]" - by jwl 11.16.2009 //Read form to see if radio set var currentRadioName = "" for(x = 0; x < myForm.elements.length; x++) { my_FormType = myForm.elements[x].type; //if (my_FormType=="radio") if ((my_FormType=="radio")||(my_FormType=="checkbox")) { var my_FieldName = myForm.elements[x].name //alert ("Radio/Checkbox - my_FormType = " + my_FormType) //alert ("Radio/Checkbox - my_FieldName = " + my_FieldName) if (my_FieldName != currentRadioName) { currentRadioName = my_FieldName var myRadio = myForm.elements[my_FieldName]; //alert ("Radio/Checkbox - my_FieldName = " + my_FieldName) //alert ("Radio/Checkbox - myRadio.length = " + myRadio.length) //run through radio set - check if checked and value is "other_specify" for (ct_Radio = 0; ct_Radio < myRadio.length; ct_Radio++) { if (myRadio[ct_Radio].checked) { // value is "other_specify" set the value to be "other_[fieldname]" value if that field exists if (myRadio[ct_Radio].value == "other_specify") { //alert ("In other specify") if (myForm.elements["other_" + my_FieldName]) { //alert ("In other_" + my_FieldName ) var otherValue = myForm.elements["other_" + my_FieldName].value //need to replace commas in other box because we parse out the results from the query onto the form and multi values are joined by commas otherValue = otherValue.replace(/,/g,","); //myRadio[ct_Radio].value = myForm.elements["other_" + my_FieldName].value myRadio[ct_Radio].value = otherValue //alert ("myRadio[" + ct_Radio + "].value = *" + myRadio[ct_Radio].value + "*") } // does "other" field exist } //is radio value "other_specify" } //is this radi checked } //for radio loop } //if myfield name is not current name - go on } //if the field is radio } //loop through form elements //START - special chaeck for phone number length (3-3-4) for checkout pages - step 3 - added by jwl per stewart 11.04.2009 //alert ("myForm.name= *" + myForm.name + "*") var txt_PhoneError = "" if (myForm.name=='join') { ph_pt1_digits = 3 ph_pt2_digits = 3 ph_pt3_digits = 4 //only do for night phone since not required and earleir check checks day phone if ((myForm.evening_phone_pt3!='')||(myForm.evening_phone_pt2!='')||(myForm.evening_phone_pt1!='')) { if (myForm.evening_phone_pt3) { evening_phone_pt3 = myForm.evening_phone_pt3.value if ((evening_phone_pt3!='')&&(evening_phone_pt3.length!=ph_pt3_digits)) { txt_PhoneError = txt_error_NightPhoneWrongLength myForm.evening_phone_pt3.focus(); } } if (myForm.evening_phone_pt2) { evening_phone_pt2 = myForm.evening_phone_pt2.value if ((evening_phone_pt2!='')&&(evening_phone_pt2.length!=ph_pt2_digits)) { txt_PhoneError = txt_error_NightPhoneWrongLength myForm.evening_phone_pt2.focus(); } } if (myForm.evening_phone_pt1) { evening_phone_pt1 = myForm.evening_phone_pt1.value if ((evening_phone_pt1!='')&&(evening_phone_pt1.length!=ph_pt1_digits)) { txt_PhoneError = txt_error_NightPhoneWrongLength myForm.evening_phone_pt1.focus(); } } } if (myForm.day_phone_pt3) { day_phone_pt3 = myForm.day_phone_pt3.value if ((day_phone_pt3!='')&&(day_phone_pt3.length!=ph_pt3_digits)) { txt_PhoneError = txt_error_DayPhoneWrongLength myForm.day_phone_pt3.focus(); } } if (myForm.day_phone_pt2) { day_phone_pt2 = myForm.day_phone_pt2.value if ((day_phone_pt2!='')&&(day_phone_pt2.length!=ph_pt2_digits)) { txt_PhoneError = txt_error_DayPhoneWrongLength myForm.day_phone_pt2.focus(); } } if (myForm.day_phone_pt1) { day_phone_pt1 = myForm.day_phone_pt1.value if ((day_phone_pt1!='')&&(day_phone_pt1.length!=ph_pt1_digits)) { txt_PhoneError = txt_error_DayPhoneWrongLength myForm.day_phone_pt1.focus(); } } } if (txt_PhoneError!='') { alert(txt_PhoneError) return false } //END - special check for phone number length (3-3-4) for checkout pages - step 3 - added by jwl per stewart 11.04.2009 if (txt_error=="") { //wipe out key words here befroe submitting //var defaultValues = required_fields.split("|"); //alert ("defaultValues = *" + defaultValues + "*") for(x = 0; x < myForm.elements.length; x++) { //alert ("Field Name = *" + myForm.elements[x].name + "*") //alert ("Field Type = *" + myForm.elements[x].type + "*") //only will happen with text elements if (myForm.elements[x].type=="text") { //alert ("Field Name = *" + myForm.elements[x].name + "*") //alert ("Before Field Value = *" + myForm.elements[x].value + "*") var testValue = "|" + myForm.elements[x].value + "|" //is the value one of the default values if (defaultValues.indexOf(testValue) >=0) { myForm.elements[x].value = '' } //alert ("After Field Value = *" + myForm.elements[x].value + "*") } } myForm.submit(); return true; //return false; } else { //alert (txt_error) alert("Incorrect Information: \n\n" + txt_error + "\nPlease return to the form and correct your information.\n\nThank You.\n"); return false; } //return false; } function passwordCheck(myPassword,myPasswordConfirm) { var pwMessage = "" txt_error_NoPasswordMatch = "- the passwords you entered do not match\n"; txt_error_PasswordTooShort = "- the password must be at least 4 characters.\n"; txt_error_PasswordTooLong = "- the password must not excede 30 characters.\n"; if (myPassword!= myPasswordConfirm) { pwMessage += txt_error_NoPasswordMatch; } if ((myPassword.length) < (4)) { pwMessage += txt_error_PasswordTooShort; } if ((myPassword.length) > (30)) { pwMessage += txt_error_PasswordTooLong; } return pwMessage; } function updateRadios(my_Checkbox, my_RadioGroup) { //alert("my_Checkbox checked? = " + my_Checkbox.checked + "*") if (my_Checkbox.checked) { my_RadioGroup[0].checked = true } else { for (var i = 0; i < my_RadioGroup.length; i++) { my_RadioGroup[i].checked = false; } } } //function cliears out passed check boxes and redio group sets based on passed value (used for Designee) function uncheckCheckboxesRadios (myForm, myCheckboxes, myRadios) { //alert("myCheckboxes = " + myCheckboxes + "*") //alert("myRadios = " + myRadios + "*") myCheckboxArray = myCheckboxes.split("|") for (ct_Checkbox = 0; ct_Checkbox < myCheckboxArray.length; ct_Checkbox++) { var CheckboxName = myCheckboxArray[ct_Checkbox] myForm.elements[CheckboxName].checked = false; } myRadiosArray = myRadios.split("|") for (ct_Radio = 0; ct_Radio < myRadiosArray.length; ct_Radio++) { var RadioName = myRadiosArray[ct_Radio] //alert("RadioName = *" + RadioName + "*") var radioGroup = myForm.elements[RadioName]; //alert("radioGroup = " + radioGroup + "*") for (var i=0; i < radioGroup.length; i++) { radioGroup[i].checked = false; } } } function refreshPage(myPage) { //alert("myPage = " + myPage) document.forms[0].next_page.value = myPage; document.forms[0].submit(); } //for applying coupon code on step 1 of join function apply_coupon_code(myForm, actionPage) { //alert ("actionPage=" + actionPage) if (actionPage!='') { myForm.action = actionPage; } myForm.submit(); return true; } //for populateing maining address portion on join form (step 3) - added by jwl 1.11.10 function populateMailing(myForm) { //alert ("In populateMailing=") //alert ("myForm.billing_address_1.value=" + myForm.billing_address_1.value) var mailing_address_1 = "" var mailing_address_2 = "" var mailing_city = "" var mailing_state = "" var mailing_zip = "" var mailing_country = "" if (myForm.same_as_billing.checked) { //alert ("CHECKED - In populateMailing") mailing_first_name = myForm.billing_first_name.value mailing_last_name = myForm.billing_last_name.value mailing_address_1 = myForm.billing_address_1.value mailing_address_2 = myForm.billing_address_2.value mailing_city = myForm.billing_city.value mailing_zip = myForm.billing_zip.value myForm.mailing_first_name.value = mailing_first_name myForm.mailing_last_name.value = mailing_last_name myForm.mailing_address_1.value = mailing_address_1 myForm.mailing_address_2.value = mailing_address_2 myForm.mailing_city.value = mailing_city mailing_state = myForm.billing_state.options[myForm.billing_state.selectedIndex].value //alert ("mailing_state=" + mailing_state) for (var i = 0; i < myForm.mailing_state.length; i++) { if (myForm.mailing_state.options[i].value==mailing_state) { myForm.mailing_state.options[i].selected = true break; } } myForm.mailing_zip.value = mailing_zip mailing_country = myForm.billing_country.options[myForm.billing_country.selectedIndex].value //alert ("mailing_country=" + mailing_country) for (var i = 0; i < myForm.mailing_country.length; i++) { if (myForm.mailing_country.options[i].value==mailing_country) { myForm.mailing_country.options[i].selected = true break; } } } /* else { alert ("UN-CHECKED - In populateMailing") } */ return true; } //this function is run on step 2 of the join process. the form will submit itself on load if the new membership id is present - JWL 01.06.2012 function funcSubmitSPCreateAcctForm(form) { if (form) { if (form.membership_id) { //alert(form.membership_id.value) if (form.membership_id.value!='') { form.submit(); return true; } else { return false; } } else { //alert("form.membership_id doesn't exist") return false; } } else { //alert("No Form!") return false; } } //these function are run on creation of the SP user (success.html) the form will submit itself on load after 5 seconds if the new login id and password are present - JWL 01.06.2012 function funcSubmitSPLogin(form) { setTimeout(function(){funcSubmitSPLogin2(form)}, 5000); return true; } function funcSubmitSPLogin2(form) { if (form) { if ((form.VerLoginID) && (form.VerPassword)) { //alert(form.VerLoginID.value) //alert(form.VerPassword.value) if ((form.VerLoginID.value!='')&&(form.VerPassword.value!='')) { form.submit(); return true; } else { return false; } } else { //alert("form.membership_id doesn't exist") return false; } } else { //alert("No Form!") return false; } }