mercredi 31 décembre 2014

Ember validate required input

I have a required input which is connected to a model.


Now i want to show an error message if the required field is empty. But only if the input has been changed or the form gets submitted. So initially there should be no error even if the input is empty.


My current solution is a property named "hasChanged" which gets set by an observer on init. http://emberjs.jsbin.com/tovawezide/2/edit?html,js,output


Is there a shorter solution with less boilerplate in ember? like an build in "hasChanged"? I think my way gets confusing with more inputs.


Note: im not talking about ember-data or its isDirty property nor do i ask for validation libraries.





Aucun commentaire:

Enregistrer un commentaire