From 9b763a16cb7e598289f8b2ecfdb51387f2807095 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 5 Jul 2016 14:54:20 +0300 Subject: [PATCH] Added simple client-side validation for phones Closes #1161 --- app/js/controllers.js | 14 ++++++++++++++ app/partials/desktop/import_contact_modal.html | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index c3544a6c..e6663be6 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -171,6 +171,20 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.sendCode = function () { $timeout.cancel(nextTimeout) + var fullPhone = ($scope.credentials.phone_country || '') + ($scope.credentials.phone_number || ''); + var badPhone = !fullPhone.match(/^[\d\-+\s]+$/); + if (!badPhone) { + fullPhone = fullPhone.replace(/\D/g, ''); + if (fullPhone.length < 7) { + badPhone = true; + } + } + if (badPhone) { + $scope.progress.enabled = false + $scope.error = {field: 'phone'} + return + } + ErrorService.confirm({ type: 'LOGIN_PHONE_CORRECT', country_code: $scope.credentials.phone_country, diff --git a/app/partials/desktop/import_contact_modal.html b/app/partials/desktop/import_contact_modal.html index f89e550e..fa18eacb 100644 --- a/app/partials/desktop/import_contact_modal.html +++ b/app/partials/desktop/import_contact_modal.html @@ -2,13 +2,16 @@
-