Padel-Tournaments-System/frontend/unlogged_user/logowanie/rejestracja/toggle.js

26 lines
857 B
JavaScript

//Password toggle
const togglePassword = document.querySelector("#togglePassword");
const password = document.querySelector("#regpassword");
togglePassword.addEventListener("click", function () {
// toggle the type attribute
const type = password.getAttribute("type") === "password" ? "text" : "password";
password.setAttribute("type", type);
// toggle the icon
this.classList.toggle("bi-eye");
});
//Repeat password toggle
const togglePassword2 = document.querySelector("#togglePassword2");
const password2 = document.querySelector("#regpassword2");
togglePassword2.addEventListener("click", function () {
// toggle the type attribute
const type = password2.getAttribute("type") === "password" ? "text" : "password";
password2.setAttribute("type", type);
// toggle the icon
this.classList.toggle("bi-eye");
});