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

fitness
Kirill Pet 8 months ago
parent 74fb21358e
commit 29021ee1e5
  1. 15
      assets/js/main.js

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

Loading…
Cancel
Save