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);
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue