/* mailinglist.js ============== Contains all functions that are used to subscribe people to our mailing list. */ /* FUNCTIONS ========= fSubscribe_Check() - Called when user submits mailing list, simply runs the check and calls the grecaptcha fSubscribe_Submit() - Submits the form */ /* NOTES ===== - All multi language variables are declared here but assigned in mailinglist.php at the bottom of the body tag */ /* LOG === 29/11/2019 - Jed Merrington * File created and all code written. */ /* MULTI LANG VARIABLES ==================== Setup required variables to be set to the correct translation when the page loads. This is done at the bottom of mailinglist.php. */ // Store the translation for checking the following var sPleaseCheckTheFollowing = ""; // Store the translation for your name var sYourName = ""; // Store the translation for your email address var sYourEmailAddress = ""; // Store the translation for agree to privacy policy var sAgreeToPrivacyPolicy = ""; /* fSubscribe_Check() ================== Checks all the required fields to ensure that there are no user errors before displaying */ function fSubscribe_Check() { // Store Variable to log errors var sFormErrors = ""; // If the name isn't set if( $("#sSubscribe_Name").val().trim() == "" ) { // Add to the forms errors sFormErrors += "\n - " + sYourName; } // If the email isn't set if( $("#sSubscribe_Email").val().trim() == "" ) { // Add to the forms errors sFormErrors += "\n - " + sYourEmailAddress; } // If the privacy has been checked if( !$("#bPrivacy").is(":checked") ) { // Add to the forms errors sFormErrors += "\n - " + sAgreeToPrivacyPolicy; } /* If there are form errors */ if(sFormErrors != "") { // Alert the errors alert(sPleaseCheckTheFollowing + ": \n" + sFormErrors); // Reset google re-captcha grecaptcha.reset(); } // If there are no form errors else { // Execute the form grecaptcha.execute(); } } /* fSubscribe_Submit() =================== Simply calls the form's submit function in jQuery */ function fSubscribe_Submit() { // Call the Submit function of the form $("#fSubscribe").submit(); }