document.getElementById("mobile-menu-icon").addEventListener("click", function() { let c = document.getElementById("nav-links-mobile").classList; c.toggle("hidden"); }) function setupFormSubmission(formElementId) { var form = document.getElementById(formElementId); form.addEventListener('submit', function(e) { e.preventDefault(); var submitButton; var formElements = e.target.elements; var formData = {}; for (var i = 0; i < formElements.length; i++) { if (formElements[i].type === "submit") { submitButton = formElements[i]; } else { formData[formElements[i].name] = formElements[i].value; } } if (!submitButton) { console.error('No submit button found.'); return; } var submitButtonText = submitButton.innerText; formData.analyticsId = window.LANDING_SITE_ID; submitButton.innerText = 'Sending...'; fetch(window.LANDING_SITE_CONTACT_US_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(formData), }) .then(function(response) { console.log(response); if (response.ok) { submitButton.innerText = 'Done!'; for (var i = 0; i < formElements.length; i++) { if (formElements[i].type !== "submit") { formElements[i].value = ''; } } } else { submitButton.innerText = 'Error. Please try again.'; } }) .catch((error) => { console.error('Error:', error); }) .finally(function() { setTimeout(function() { submitButton.innerText = submitButtonText; }, 4000); }) }); } setupFormSubmission('hero-contact-us-form'); setupFormSubmission('contact-us-form');
Expert insurance strategies tailored to safeguard your wealth and loved ones.
Contact Us