I want to know when the textbox is empty and when user click the submit button the error message will need to show. Please help me.
This is my template register.hbs code
{{paper-input
label="E-mail"
type="email"
value=email
onChange=(action (mut email))
icon="email"
}}
{{#paper-button raised=true primary=true onClick=(action "register")}}Register{{/paper-button}}
and this is my controller register.js code
email: null,
actions: {
register() {
var data = {
email: this.get('email'),
};
var record = this.store.createRecord('register', data);
record.save().then((response) => {
this.set('email', null);
this.transitionToRoute('activation');
});
}
}
Just put something like:
trim() removes possible whitespaces from the mail and a empty or null string is falsy in javascript:
More on trim
More on what evaluates to True/False for strings