Skip to content

Commit

Permalink
Validating empty mail and removing canRegister
Browse files Browse the repository at this point in the history
  • Loading branch information
tfloxolodeiro committed Apr 14, 2021
1 parent 411bedf commit 0e3bd65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions app/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ import Controller from '@ember/controller';
export default Controller.extend({
avatardb: service(),
pilasBloquesApi: service(),
registerData: {},
registerData: {email:''},
validUsername: true,
validEmail: true,
validParentName: true,
validDNI: true,
canRegister: computed('validUsername', 'validEmail', 'validParentName', 'validDNI', function() {
return this.validUsername && this.validEmail && this.validParentName && this.validDNI
}),


avatars: computed('avatardb', function () {
return this.avatardb.allAvatars()
}),
Expand All @@ -23,7 +17,7 @@ export default Controller.extend({
validate: (mail) => {
// https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript
const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(mail)
return re.test(mail) || mail == ''
}
}],

Expand Down
2 changes: 1 addition & 1 deletion app/templates/register.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<br><br>
<ProgressButton class="link" type="submit"
@isDisabled={{not canRegister}}
@isDisabled={{not validUsername}}
@loading={{ pilasBloquesApi.loading.register }}>
Registrar
</ProgressButton>
Expand Down

0 comments on commit 0e3bd65

Please sign in to comment.