Skip to content

Commit

Permalink
adding button disable mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
beczkowb committed Feb 24, 2017
1 parent c4b4499 commit 0e2ef94
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions openchat/app/components/register-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ export default Ember.Component.extend({
validators: []
}),

formInvalid: true,
init() {
this._super(...arguments);
let passwordInput = this.get('password');
let confirmPassword = this.get('confirmPassword');
confirmPassword.set(
'validators',
[new SameAs(passwordInput)]
);
confirmPassword.validate();
},

passwordChanged: Ember.observer('password.{value}', function () {
this.get('confirmPassword').validate();
}),

showUsernameErrors: Ember.computed('username.{pristine,errors}', function () {
return !this.get('username.pristine') && this.get('username.errors');
Expand All @@ -38,14 +51,10 @@ export default Ember.Component.extend({
return !this.get('confirmPassword.pristine') && this.get('confirmPassword.errors');
}),

init() {
this._super(...arguments);
let passwordInput = this.get('password');
let confirmPassword = this.get('confirmPassword');
confirmPassword.set(
'validators',
[new SameAs(passwordInput)]
);
},
formInvalid: Ember.computed('username.{errors}', 'email.{errors}', 'password.{errors}', 'confirmPassword.{errors}', function () {
return this.get('username.errors') || this.get('email.errors') || this.get('password.errors') || this.get('confirmPassword.errors');
}),



});

0 comments on commit 0e2ef94

Please sign in to comment.