Corrected the username validation

This commit is contained in:
Alex Tselegidis 2021-12-18 19:02:35 +01:00
parent f4146d58e9
commit e8011afb9a

View file

@ -78,8 +78,7 @@ App.Pages.Account = (function () {
throw new Error(App.Lang.invalid_email); throw new Error(App.Lang.invalid_email);
} }
if ($username.attr('already-exists') === 'true') { if ($username.hasClass('is-invalid')) {
$username.addClass('is-invalid');
throw new Error(App.Lang.username_already_exists); throw new Error(App.Lang.username_already_exists);
} }
@ -169,10 +168,10 @@ App.Pages.Account = (function () {
const username = $username.val(); const username = $username.val();
App.Http.Account.validateUsername(username).done((response) => { App.Http.Account.validateUsername(username).done((response) => {
if (response.is_valid) { const isValid = response.is_valid;
$username.removeClass('is-invalid already-exists'); $username.toggleClass('is-invalid', !isValid);
} else { if (!isValid) {
$username.addClass('is-invalid already-exists'); Backend.displayNotification(App.Lang.username_already_exists);
} }
}); });
} }