Since emberjs has finally been released I thought that I’d update my my approach to form validation to make use of components and a simple controller mixin to keep things DRY.
With this validation solution there are a few thing that I want to achieve:
* Simplified templating. Each input is more than just a simple text box, but comprises label, editbox, validation text and visual feedback. I don’t want to have to type/copy this for every field.
* Validation encapsulation. Each validation form element should be self contained and minimise spaghetti code.
* Async validation support. Some validations happen on the server side (eg, check if email is taken).
* Unobtrusive UI. When a form is initially rendered, don’t immediately start telling the user what they did wrong. Ideally only inform them as they go (after each field loses focus) or when they try to submit.
* Controller integration. The controller should know via a single property if the form state is valid.
Your new post is loading...