document.addEventListener("DOMContentLoaded", function () { const emailInput = document.querySelector('input[type="email"]'); if (emailInput) { emailInput.addEventListener("blur", function () { const emailValue = emailInput.value.trim(); const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // Remove any previous error state emailInput.classList.remove("has-error"); // Check if email is invalid if (emailValue && !emailRegex.test(emailValue)) { emailInput.classList.add("has-error"); } }); } });