I tried onblur, focus-out, focusout, onfocusout, blur and focusOut throws error as it's a tagless component. None of them are working.
I'm trying to build a user form and validate the input when the user blur's from the field.
I'm using the below addon's together
- https://github.com/martndemus/ember-form-for
- https://github.com/poteto/ember-changeset
- https://github.com/poteto/ember-changeset-validations
Component Template File
<p></p>
<p></p>
<p></p>
Component Javascript File
import Component from '@ember/component';
import { get } from '@ember/object';
import Changeset from 'ember-changeset';
import lookupValidator from 'ember-changeset-validations';
import UserValidations from '../../validations/user';
export default Component.extend({
init() {
this._super(...arguments);
this.user = new Changeset(get(this, 'model'), lookupValidator(UserValidations), UserValidations);
},
actions:{
validateOnBlur(changeset, property){
debugger
},
async submit(changeset){
await changeset.validate();
if(changeset.isValid){
changeset.save();
}
}
}
});
Validator
import {
validatePresence,
validateLength,
validateFormat
} from 'ember-changeset-validations/validators';
export default {
name: validatePresence(true),
email: [
validatePresence(true),
validateFormat({ type: 'email' })
],
password: [
validatePresence(true),
validateLength({ min: 8 })
]
};
Aucun commentaire:
Enregistrer un commentaire