fix: correctly get checkbox data from contact form

This commit is contained in:
2025-08-25 23:59:36 -05:00
parent f2cdc9cdc2
commit 2db0050f44

View File

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