document.addEventListener("DOMContentLoaded", () => {
  const resetForm = document.getElementById("resetForm");
  const emailInput = document.getElementById("emailInput");
  const emailError = document.getElementById("emailInput-error"); 

  if (resetForm) {
    resetForm.addEventListener("submit", (e) => {
      e.preventDefault(); 

      const emailValue = emailInput.value.trim();

      if (emailValue === "" || !emailValue.includes("@")) {
        if (emailError) {
          emailError.classList.remove("hidden");
          emailError.style.display = "block";
        }
        emailInput.classList.add("border-red-500"); 
        return;
      }

      window.location.href = "./otp-code-varify.html";
    });

    emailInput.addEventListener("input", () => {
      if (emailError) {
        emailError.classList.add("hidden");
        emailError.style.display = "none";
      }
      emailInput.classList.remove("border-red-500");
    });
  }
});
