From e8011afb9ac7040d38e1a0ec796d876804130be4 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 18 Dec 2021 19:02:35 +0100 Subject: [PATCH] Corrected the username validation --- assets/js/pages/account.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/assets/js/pages/account.js b/assets/js/pages/account.js index bc9f8f19..c188011e 100644 --- a/assets/js/pages/account.js +++ b/assets/js/pages/account.js @@ -78,8 +78,7 @@ App.Pages.Account = (function () { throw new Error(App.Lang.invalid_email); } - if ($username.attr('already-exists') === 'true') { - $username.addClass('is-invalid'); + if ($username.hasClass('is-invalid')) { throw new Error(App.Lang.username_already_exists); } @@ -169,10 +168,10 @@ App.Pages.Account = (function () { const username = $username.val(); App.Http.Account.validateUsername(username).done((response) => { - if (response.is_valid) { - $username.removeClass('is-invalid already-exists'); - } else { - $username.addClass('is-invalid already-exists'); + const isValid = response.is_valid; + $username.toggleClass('is-invalid', !isValid); + if (!isValid) { + Backend.displayNotification(App.Lang.username_already_exists); } }); }