Your message has been received. A member of our team will get back to you shortly.
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector('form[data-validate="true"]');
if (!form) return;
const emailInput = form.querySelector('[data-type="email"]');
const phoneInput = form.querySelector('[data-type="phone"]');
function isValidEmail(email) {
// Requires a domain and a valid TLD (e.g. .com, .io, .net, etc.)
return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email);
}
if (phoneInput) {
phoneInput.addEventListener("input", function () {
this.value = this.value.replace(/[^0-9\-\+\(\)\s]/g, '');
});
}
form.addEventListener("submit", function (e) {
let errors = [];
if (emailInput) {
const emailValue = emailInput.value.trim();
if (!isValidEmail(emailValue)) {
errors.push("Please enter a valid email address (e.g., user@example.com).");
}
}
if (phoneInput) {
const phoneValue = phoneInput.value.trim();
const phonePattern = /^[\+\d]?[\d\s\-\(\)]{7,20}$/;
if (!phonePattern.test(phoneValue)) {
errors.push("Please enter a valid phone number (e.g., +1 (123) 456-7890).");
}
}
if (errors.length > 0) {
e.preventDefault(); // Stop native form submission
e.stopImmediatePropagation(); // ✅ Prevent Webflow from submitting it
alert(errors.join("\n"));
}
}, true); // ✅ Use capture phase to run before Webflow's own listener
});