From 29021ee1e50aee7b81d88d2d06fea4bb07b590d7 Mon Sep 17 00:00:00 2001 From: Kirill Pet Date: Sat, 21 Dec 2024 15:03:49 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=D0=BC=D0=B0=D1=81=D0=BA=D0=B8=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D1=84=D0=BE=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/main.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index ab8ea02..8ffba6c 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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 ' + } + }); })