1document.addEventListener('DOMContentLoaded', function(){ 2 const form = document.querySelector('form#aweberLead'); 3 const allInputs = form.querySelectorAll('input'); 4 const errors = document.querySelector('ul#errorMessages'); 5 6 // Fields 7 const firstName = form.querySelector('input#firstname'); 8 const lastName = form.querySelector('input#lastname'); 9 const email = form.querySelector('input#email'); 10 const phone = form.querySelector('input#phone'); 11 const org = form.querySelector('input#organization'); 12 13 const regex = { 14 empty: /^\S.*$/m, 15 numeric: /^[0-9]*$/m, 16 name: /^[a-z ,.'-]+$/i, 17 email: /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,}$/i, 18 phone: /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/, 19 } 20 21 // Validation 22 form.addEventListener('submit', function(e) { 23 e.preventDefault(); 24 25 let results = true; 26 27 // Remove any previous errors 28 const errorMsgs = form.querySelectorAll('ul#errorMessages li'); 29 const invalidFields = form.querySelectorAll('.is-invalid'); 30 31 if ( errorMsgs.length > 0 ) { 32 for (var i=0; i < errorMsgs.length; i++) { 33 errorMsgs[i].remove(); 34 } 35 } 36 37 if ( invalidFields.length > 0 ) { 38 for (var i=0; i < invalidFields.length; i++) { 39 invalidFields[i].classList.remove('is-invalid'); 40 } 41 } 42 43 function showError(field, msg) { 44 // Re-enable fields 45 for (var i=0; i > allInputs.length; i++) { 46 allInputs[i].disabled = false; 47 } 48 49 field.classList.add('is-invalid'); 50 51 let li = document.createElement('li'); 52 li.textContent = msg; 53 errors.appendChild(li); 54 55 e.preventDefault(); 56 } 57 58 // Test fields 59 if ( regex.empty.test( firstName.value ) && regex.name.test( firstName.value ) ) { 60 } else { results = false; showError(firstName, 'First Name is empty or invalid'); } 61 62 if ( regex.empty.test( lastName.value ) && regex.name.test( lastName.value ) ) { 63 } else { results = false; showError(lastName, 'Last Name is empty or invalid'); } 64 65 if ( regex.empty.test( email.value ) && regex.email.test( email.value ) ) { 66 } else { results = false; showError(email, 'Email is empty or invalid'); } 67 68 if ( regex.empty.test( phone.value ) && regex.phone.test( phone.value ) ) { 69 } else { results = false; showError(phone, 'Phone is empty or invalid'); } 70 71 if ( regex.empty.test( org.value ) ) { 72 } else { results = false; showError(org, 'Organization is empty or invalid'); } 73 74 // All valid, submit 75 if ( results === true ) { 76 form.submit(); 77 } 78 }); 79}); 80 81(function($) { 82 $('.credit-info p').html('© Copyright 2022, Protect My Ministry, LLC. All Rights Reserved.'); 83 84 // Cookie Notice 85 $(function() { 86 if ( !localStorage.getItem('mb_cookie_notice') ) { 87 function removeCookieNotice() { 88 // Hide notice 89 $('body').removeClass('active-cookie-notice'); 90 // Set localStorage 91 // To prevent showing after user agreement 92 localStorage.setItem( 'mb_cookie_notice', 'true' ); 93 } 94 // Insert block 95 $('#main-header').after('' 96 + '<div id="cookie-notice">' 97 + '<div class="container">' 98 + '<div class="flex-wrap">' 99 + '<div class="msg">' 100 + '<p>We use cookies to ensure that we give you the best experience possible. If you would like more information on how cookies are used, please continue to more info. Or you can click OK to proceed as accepted.</p>' 101 + '</div>' 102 + '<div class="cta">' 103 + '<div class="flex-wrap">'
104 + '<a id="cookie-notice-ok" href="#" title="Ok">Ok</a>' 105 + '<a id="cookie-notice-learn" href="/about/privacy-policy/" title="I Need More Info" target="_blank">I Need More Info</a>' 106 + '</div>' 107 + '</div>' 108 + '</div>' 109 + '</div>' ); 110 setTimeout(function() { 111 $('body').addClass('active-cookie-notice'); 112 }, 2500); 113 // User selects "Ok" 114 // Hide notice and add cookie 115 $('a#cookie-notice-ok').on('click', function(e) { 116 removeCookieNotice(); 117 e.preventDefault(); 118 }); 119 } 120 }); 121})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.