fix маски телефона

This commit is contained in:
Kirill Pet
2024-12-21 15:03:49 +03:00
parent 74fb21358e
commit 29021ee1e5

View File

@@ -274,7 +274,7 @@ phoneInputs.forEach(phoneInput => {
let value = phoneInput.value;
if (value.length == 0) {
phoneInput.value += '+7 '
phoneInput.value = '+7 '
}
}
@@ -286,15 +286,24 @@ phoneInputs.forEach(phoneInput => {
if (value.charAt(0) == '+' && length == 1) return;
if (isNaN(data)) {
phoneInput.value = data.slice(0, -1)
phoneInput.value = value.slice(0, -1);
}
if (typeof data != 'object') {
if (length == 6 || length == 10) {
if (length == 2 || length == 6 || length == 10) {
phoneInput.value = value + ' ';
}
if (length == 3 || length == 7 || length == 11) {
if (data != ' ') {
phoneInput.value = value.slice(0, -1) + ' ' + data;
}
}
}
if (length <= 3) {
phoneInput.value = '+7 '
}
});
})