48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
function togglePassword(inputId) {
|
|
const input = document.getElementById(inputId);
|
|
const button = event.target;
|
|
|
|
if (input.type === 'password') {
|
|
input.type = 'text';
|
|
button.textContent = '🙈';
|
|
} else {
|
|
input.type = 'password';
|
|
button.textContent = '👁️';
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const form = document.querySelector('.auth-form');
|
|
const emailInput = document.getElementById('email');
|
|
const passwordInput = document.getElementById('password');
|
|
|
|
[emailInput, passwordInput].forEach(input => {
|
|
input.addEventListener('focus', function () {
|
|
this.parentElement.classList.add('focused');
|
|
});
|
|
|
|
input.addEventListener('blur', function () {
|
|
this.parentElement.classList.remove('focused');
|
|
});
|
|
});
|
|
|
|
form.addEventListener('submit', function (e) {
|
|
const email = emailInput.value.trim();
|
|
const password = passwordInput.value.trim();
|
|
|
|
if (!email || !password) {
|
|
e.preventDefault();
|
|
alert('Please fill in all fields');
|
|
return false;
|
|
}
|
|
|
|
if (!email.includes('@')) {
|
|
e.preventDefault();
|
|
alert('Please enter a valid email address');
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
});
|