From 2db0050f447d3b393fa9fd3e0dc5ca1d53eb3097 Mon Sep 17 00:00:00 2001 From: dereklseitz Date: Mon, 25 Aug 2025 23:59:36 -0500 Subject: [PATCH] fix: correctly get checkbox data from contact form --- src/scripts/contact-form.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/scripts/contact-form.js b/src/scripts/contact-form.js index e7b781d..f344f7c 100644 --- a/src/scripts/contact-form.js +++ b/src/scripts/contact-form.js @@ -62,11 +62,16 @@ form.addEventListener("submit", function(event) { const phone = document.getElementById("phone").value.trim(); const contactMethod = document.querySelector('input[name="contact-method"]:checked')?.value; const message = document.getElementById("message").value.trim(); - const privacyAccepted = document.getElementById("privacy-policy").checked; + const privacyAccepted = form.querySelector('#privacy-policy').checked; let hasErrors = false; // Validation logic... + if (!privacyAccepted) { + showMessage("Privacy Policy must be accepted before submitting.", true); + hasErrors = true; + } + if (!firstName) { showError("first-name", "Please enter your first name."); hasErrors = true; @@ -113,12 +118,6 @@ form.addEventListener("submit", function(event) { hasErrors = true; } - if (!privacyAccepted) { - showMessage("Privacy Policy must be accepted before submitting.", true); - hasErrors = true; - } - - if (!hasErrors) { // Package the form data, including the hCaptcha token const formData = {