registration: Disable submit button when username invalid.

This commit is contained in:
Max Goodman
2012-09-10 17:11:52 -07:00
parent 49adee7c15
commit 9424f5ad81
2 changed files with 9 additions and 0 deletions

View File

@@ -2684,6 +2684,10 @@ body.rulespage-body {
color: #369;
}
button.button[disabled] {
color: gray;
}
.button #cover {
position: relative;
}

View File

@@ -210,6 +210,8 @@ r.ui.RegisterForm = function() {
this.checkUsernameDebounced = _.debounce($.proxy(this, 'checkUsername'), 500)
this.$user = this.$el.find('[name="user"]')
this.$user.on('keyup', $.proxy(this, 'usernameChanged'))
this.$submit = this.$el.find('.submit button')
}
r.ui.RegisterForm.prototype = $.extend(new r.ui.Form(), {
usernameChanged: function() {
@@ -221,6 +223,7 @@ r.ui.RegisterForm.prototype = $.extend(new r.ui.Form(), {
}
this.$el.find('.error.field-user').hide()
this.$submit.attr('disabled', false)
this.$el.removeClass('name-available name-taken')
this.checkUsernameDebounced(name)
this.$el.toggleClass('name-checking', !!name)
@@ -240,8 +243,10 @@ r.ui.RegisterForm.prototype = $.extend(new r.ui.Form(), {
displayUsernameStatus: function(result) {
if (result.json && result.json.errors) {
this.showErrors(result.json.errors)
this.$submit.attr('disabled', true)
} else {
this.$el.addClass(result ? 'name-available' : 'name-taken')
this.$submit.attr('disabled', result == false)
}
},