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 = {