fix: correctly get checkbox data from contact form
This commit is contained in:
@@ -62,11 +62,16 @@ form.addEventListener("submit", function(event) {
|
|||||||
const phone = document.getElementById("phone").value.trim();
|
const phone = document.getElementById("phone").value.trim();
|
||||||
const contactMethod = document.querySelector('input[name="contact-method"]:checked')?.value;
|
const contactMethod = document.querySelector('input[name="contact-method"]:checked')?.value;
|
||||||
const message = document.getElementById("message").value.trim();
|
const message = document.getElementById("message").value.trim();
|
||||||
const privacyAccepted = document.getElementById("privacy-policy").checked;
|
const privacyAccepted = form.querySelector('#privacy-policy').checked;
|
||||||
|
|
||||||
let hasErrors = false;
|
let hasErrors = false;
|
||||||
|
|
||||||
// Validation logic...
|
// Validation logic...
|
||||||
|
if (!privacyAccepted) {
|
||||||
|
showMessage("Privacy Policy must be accepted before submitting.", true);
|
||||||
|
hasErrors = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!firstName) {
|
if (!firstName) {
|
||||||
showError("first-name", "Please enter your first name.");
|
showError("first-name", "Please enter your first name.");
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
@@ -113,12 +118,6 @@ form.addEventListener("submit", function(event) {
|
|||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!privacyAccepted) {
|
|
||||||
showMessage("Privacy Policy must be accepted before submitting.", true);
|
|
||||||
hasErrors = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!hasErrors) {
|
if (!hasErrors) {
|
||||||
// Package the form data, including the hCaptcha token
|
// Package the form data, including the hCaptcha token
|
||||||
const formData = {
|
const formData = {
|
||||||
|
Reference in New Issue
Block a user