diff --git a/src/scripts/contact-form.js b/src/scripts/contact-form.js
index 03a0b1a..ffe67a3 100644
--- a/src/scripts/contact-form.js
+++ b/src/scripts/contact-form.js
@@ -29,22 +29,9 @@ form.addEventListener("submit", function(event) {
console.warn("Honeypot field was filled. Blocking submission.");
// You might want to display a message to the user,
// but it's often better to fail silently to not alert the bot.
- // For debugging, you can add an alert:
- // alert("Submission failed due to security check.");
return; // This is the most important part: stop the function here.
}
- // Get the hCaptcha response token
- const hCaptchaResponse = document.querySelector('[name="h-captcha-response"]').value;
-
- // Check if the hCaptcha token is missing
- if (!hCaptchaResponse) {
- // You might want to display a user-facing error here
- console.warn("hCaptcha token is missing. Submission blocked.");
- alert("Please complete the hCaptcha verification.");
- hasErrors = true;
- }
-
// Get values
const firstName = document.getElementById("first-name").value.trim();
const lastName = document.getElementById("last-name").value.trim();
@@ -88,9 +75,9 @@ form.addEventListener("submit", function(event) {
}
// Phone — match format: 123-456-7890
- const phonePattern = /^(\(?\d{3}\)?[\s-.]?\d{3}[\-.\s]?\d{4})$/;
+ const phonePattern = /^(\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})$/;
if (!phonePattern.test(phone)) {
- showError("phone", "Phone number format is invalid.");
+ showError("phone", "Phone number must be in the format 123-456-7890.");
hasErrors = true;
}
@@ -111,7 +98,6 @@ form.addEventListener("submit", function(event) {
contactMethod: contactMethod,
message: message,
url: honeypotField,
- hCaptchaResponse: hCaptchaResponse
};
// Send the data to the backend using fetch()
@@ -143,10 +129,10 @@ form.addEventListener("submit", function(event) {
});
form.addEventListener("reset", function (event) {
- const confirmed = confirm("Are you sure you want to clear the form?");
- if (!confirmed) {
+ const confirmed = confirm("Are you sure you want to clear the form?");
+ if (!confirmed) {
event.preventDefault();
return;
- }
- clearErrors();
-});
+ }
+ clearErrors();
+});
\ No newline at end of file