document.getElementById('g-recaptcha-response').value = "token"; document.querySelector('#submitForm').onclick = e => { var button = document.querySelector('#submitForm') if (button.classList.contains("request-in-progress")) return false; button.classList.add("request-in-progress") grecaptcha.ready(() => { grecaptcha.execute('6LfLCt8UAAAAAG92TAKPokaWECaT7Xp00XA9aVKd', { action: 'submit_form' }) .then((token) => document.getElementById('g-recaptcha-response').value = token) .then(() => { var iuuvcjvfkdfdjbhvehrjkvgefjhugggg = document.getElementById('iuuvcjvfkdfdjbhvehrjkvgefjhugggg') if (!iuuvcjvfkdfdjbhvehrjkvgefjhugggg.checkValidity()) { iuuvcjvfkdfdjbhvehrjkvgefjhugggg.reportValidity() button.classList.remove("request-in-progress") return false } const data = new FormData(document.querySelector('#iuuvcjvfkdfdjbhvehrjkvgefjhugggg')); fetch(document.querySelector('#iuuvcjvfkdfdjbhvehrjkvgefjhugggg').action, { method: 'post', body: data, }) .then(r => { if (r.ok) return r; throw r }) .then(r => displayFeedback({}, true)) .then(() => { iuuvcjvfkdfdjbhvehrjkvgefjhugggg.reset() button.classList.remove("request-in-progress")}) .catch(r => { button.classList.remove("request-in-progress") displayFeedback(r) }) return false }) }); return false }; var condition = { init: () => { var fields = [...document.querySelectorAll("input, select")] fields.forEach(field => field.onchange = e => { condition.change(e) }) condition.render() }, change: e => { var target = conditions['360000621300'].find(cond => e.target.name == cond.parent_field_id && e.target.value == cond.value) if (target) { conditions['360000621300'] .filter(cond => cond.parent_field_id == target.parent_field_id) .map(cond => cond.active = false) target.active = true condition.render() } else { conditions['360000621300'] .filter(cond => e.target.name == cond.parent_field_id) .map(cond => cond.active = false) condition.render() } }, render: e => { conditions['360000621300'].forEach(cond => { if (!cond.active) { condition.deactive(cond) } }) conditions['360000621300'].forEach(cond => { if (cond.active) { condition.active(cond) } }) }, deactive: cond => cond.child_fields.forEach(child => document.querySelectorAll(`label[for="${child.id}"], [name="${child.id}"]`).forEach(l => { l.classList.add("hidden") ; l.classList.remove("required") l.removeAttribute("required"); })), active: cond => cond.child_fields.forEach(child => document.querySelectorAll(`label[for="${child.id}"], [name="${child.id}"]`).forEach(l => { l.classList.remove("hidden"); if (child.is_required) { l.setAttribute("required", "true"); l.classList.add("required") } })) }; condition.init(); function paramCheck() { var setFieldParams = {} new URL(window.location.href).searchParams.forEach((value, key) => { if (key.includes('setField-')) { key = key.replace("setField-", "") var el = document.getElementsByName(key)[0] if (!el) { // console.log(key, "not found") return } el.value = value; el.dispatchEvent(new Event('change')); setFieldParams[key] = value; } }); } paramCheck()