

const togglePassword = document.querySelector("#togglePassword");
const password = document.querySelector("#password");

if (togglePassword && password) {
  togglePassword.addEventListener("click", function () {
    const type = password.getAttribute("type") === "password" ? "text" : "password";
    password.setAttribute("type", type);

    // icon switch
    if (type === "password") {
      this.classList.remove("fa-eye-slash");
      this.classList.add("fa-eye");
    } else {
      this.classList.remove("fa-eye");
      this.classList.add("fa-eye-slash");
    }
  });
}






