Corrected the username validation
This commit is contained in:
parent
f4146d58e9
commit
e8011afb9a
1 changed files with 5 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue