Создана система регистрации пользователя
This commit is contained in:
parent
13754eecc3
commit
229826acc3
10 changed files with 1332 additions and 40 deletions
|
|
@ -43,7 +43,10 @@ import { SITE_URL } from '@constants';
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">Пароль</label>
|
||||
<label for="password">
|
||||
Пароль
|
||||
<span class="hint">От 8 до 12 символов</span>
|
||||
</label>
|
||||
<div class="password-wrapper">
|
||||
<input
|
||||
type="password"
|
||||
|
|
@ -52,6 +55,8 @@ import { SITE_URL } from '@constants';
|
|||
placeholder="••••••••"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
minlength="8"
|
||||
maxlength="12"
|
||||
/>
|
||||
<button type="button" class="toggle-password" data-target="password">
|
||||
<svg class="eye-open" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
|
@ -149,6 +154,15 @@ import { SITE_URL } from '@constants';
|
|||
color: #1e3050;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-group label .hint {
|
||||
color: #94a3b8;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
|
|
@ -361,6 +375,10 @@ import { SITE_URL } from '@constants';
|
|||
return regex.test(value);
|
||||
}
|
||||
|
||||
function validatePassword(value: string): boolean {
|
||||
return value.length >= 8 && value.length <= 12;
|
||||
}
|
||||
|
||||
document.querySelectorAll('.toggle-password').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const targetId = button.getAttribute('data-target');
|
||||
|
|
@ -384,7 +402,12 @@ import { SITE_URL } from '@constants';
|
|||
});
|
||||
|
||||
passwordInput?.addEventListener('input', () => {
|
||||
if (passwordInput.value) {
|
||||
if (passwordInput.value.length > 12) {
|
||||
passwordInput.value = passwordInput.value.slice(0, 12);
|
||||
}
|
||||
if (passwordInput.value && !validatePassword(passwordInput.value)) {
|
||||
showError(passwordInput, 'Пароль должен быть 8-12 символов');
|
||||
} else {
|
||||
clearError(passwordInput);
|
||||
}
|
||||
});
|
||||
|
|
@ -414,6 +437,9 @@ import { SITE_URL } from '@constants';
|
|||
if (!password || password.trim() === '') {
|
||||
showError(passwordInput, 'Введите пароль');
|
||||
hasErrors = true;
|
||||
} else if (!validatePassword(password)) {
|
||||
showError(passwordInput, 'Пароль должен быть от 8 до 12 символов');
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (hasErrors) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue