Changes in code after first review from Google AI Studio
Deploy to Production / deploy (push) Successful in 12s

This commit is contained in:
popovskik committed 2026-04-09 09:29:55 +02:00
1 parent 4c58da3eba
commit 2807a55b26
7 files changed
+11865 -11

No files matched your search

+25 -6
View File
@@ -136,6 +136,9 @@ function setupContactForm() {
const fields = Array.from(form.querySelectorAll("[data-required], [type='email']"));
const status = form.querySelector("[data-form-status]");
const action = (form.getAttribute("action") || "").trim();
const hasExternalEndpoint = /^https?:\/\//i.test(action);
const hasPlaceholderEndpoint = action.includes("YOUR_ID_HERE");
const validators = {
email: (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
@@ -209,14 +212,30 @@ function setupContactForm() {
return;
}
event.preventDefault();
if (status) {
status.textContent = "Thanks. Your message structure is validated and ready for backend integration.";
status.classList.add("is-success");
status.classList.remove("is-success");
}
form.reset();
fields.forEach((field) => setFieldError(field, ""));
if (!hasExternalEndpoint || hasPlaceholderEndpoint) {
event.preventDefault();
if (status) {
status.textContent = hasPlaceholderEndpoint
? "Replace the Formspree form ID to enable live message delivery."
: "Thanks. Your message structure is validated and ready for backend integration.";
status.classList.toggle("is-success", !hasPlaceholderEndpoint);
}
if (!hasPlaceholderEndpoint) {
form.reset();
fields.forEach((field) => setFieldError(field, ""));
}
return;
}
if (status) {
status.textContent = "Submitting your message...";
}
});
}