feat: add password toggle visibility and rename forgot-password to change-password

This commit is contained in:
Wini_Fy
2026-02-10 10:24:35 +07:00
parent 2ddf43c139
commit 5e7de227ec
8 changed files with 116 additions and 27 deletions

View File

@@ -0,0 +1,47 @@
document.addEventListener('DOMContentLoaded', function() {
const toggleButtons = document.querySelectorAll('.password-toggle-btn');
toggleButtons.forEach(button => {
// Hover effect logic
button.addEventListener('mouseenter', function() {
this.style.color = 'var(--primary-color)';
});
button.addEventListener('mouseleave', function() {
this.style.color = '#666';
});
button.addEventListener('click', function() {
// Find the input element within the same container
// We assume the structure is container > input + button
// or button is absolutely positioned relative to container
// The safest way is to look for the input in the parent container
const container = this.parentElement;
const input = container.querySelector('input');
if (input) {
const type = input.getAttribute('type') === 'password' ? 'text' : 'password';
input.setAttribute('type', type);
const icon = this.querySelector('i');
if (type === 'text') {
icon.classList.remove('fa-eye');
icon.classList.add('fa-eye-slash');
this.setAttribute('aria-label', 'Hide password');
} else {
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
this.setAttribute('aria-label', 'Show password');
}
}
});
// Add keyboard accessibility
button.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
this.click();
}
});
});
});