/
mr.fork
/
learning-git
Обзор
Документация
Войти
/
mr.fork
/
learning-git
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
auth
resources/js/custom.js
47 строк
2 KB
doubleW
login register Auth
21 окт 2025, 14:45
21 окт 2025, 14:45
db64543
Код
Авторство
О чём код?
document.addEventListener('DOMContentLoaded', function () { const fioInput = document.getElementById('fio'); if (fioInput) { fioInput.addEventListener('input', function () { let value = this.value; let words = value.split(/\s+/).map(word => { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); }); this.value = words.join(' ').trim(); }); } }); document.addEventListener('DOMContentLoaded', function () { const phoneInput = document.getElementById('phone'); if (phoneInput) { phoneInput.addEventListener('input', function () { let value = this.value.replace(/[^\d+]/g, ''); // Удаляем всё, кроме цифр и + // Применяем маску только если есть +7 if (value.startsWith('+7')) { let digitsOnly = value.replace(/[^\d]/g, ''); let formatted = '+7 '; if (digitsOnly.length > 3) { formatted += digitsOnly.substring(2, 5); } if (digitsOnly.length > 6) { formatted += ' ' + digitsOnly.substring(5, 8); } if (digitsOnly.length > 9) { formatted += ' ' + digitsOnly.substring(8, 10); } if (digitsOnly.length > 11) { formatted += ' ' + digitsOnly.substring(10, 12); } this.value = formatted; } else if (value) { this.value = '+7'; } }); } });