SPARK FORM: SPARK CUSTOM REGISTRATION FORM CODE First Name * Last Name * Email * Phone Number * Postal Code * When are you looking to move? * SelectFall 2022Winter 2022Spring 2023Summer 2023 What type of suite are you looking for? Select1 Bed1 Bed + Den2 Bed2 Bed + Den3 Bed Register with The Millway window.onload = function() { // Hides spam trap document.getElementById("are_you_simulated").style.display = "none"; // Hides Employer/Brokerage field at the start hideBrokerageEmployer(); } var submitting = false; var agentField = document.getElementById("agent"); function hideBrokerageEmployer() { if (agentField === null) { return }; if (agentField.options[agentField.selectedIndex].text == "No") { document.getElementById("hidden-agent").style.display = "none"; } else { document.getElementById("hidden-agent").style.display = "table"; } } // Show/Hides Brokerage/Employer field based on Yes/No selection. if (agentField) { document.getElementById("agent").onchange = function() { hideBrokerageEmployer(); } } function submitRegistrationForm(element) { var form = document.querySelector("body#spark-registration-form form, form#spark-registration-form"); var missing = ""; var required = { contact_email: "Email" }; var customRequired = document.querySelectorAll("input:required, textarea:required, select:required"); var questionsRequired = {answers_10428: 'Where did you hear about us?', answers_10570: 'When are you looking to move?', answers_10604: 'Do you have a budget in mind?'}; // Adds custom required inputs to the 'required' object for (var i = 0; i < customRequired.length; i++) { required[customRequired[i].id] = customRequired[i].parentNode.firstElementChild.innerHTML.replace("*", ""); } // Adds required question inputs to the 'required' object for (var key in questionsRequired) { required[key] = questionsRequired[key]; } // Iterates through required fields and adds any that have // not been populated to 'missing' list for (var key in required) { var elements = Array.from(document.querySelectorAll("[id^='"+ key + "']")); if (elements.length > 0) { var missing_field = true; elements.forEach(function (el) { if ((el.length < 1) || (el && ((el.type == "checkbox" && el.checked) || (el.type == "radio" && el.checked) || ((el.type != "radio" && el.type != "checkbox") && el.value) || (document.getElementById(key + "_other_text") && document.getElementById(key + "_other_text").value)))) { missing_field = false; } }); if (missing_field) { missing += "- "+ required[key] + "\r\n" } } } // Tests email input value against RFC 5322 Official Standard Email Regex var email = document.getElementById("contact_email").value; if (!/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/.test(email)) { missing += "- Email is invalid\r\n"; } if (missing != "") { alert("The following fields are incomplete:\r\n"+ missing); return false; } // Prevents duplicate submissions if (submitting) { return false; } submitting = true // If you are hosting this form on your own site and have reCAPTCHA enabled, // ensure that this is populated with your own site key, as well as include // the following script before this code: //