> 2. distinguished between 'untouched empty' and 'deleted it all empty'
> values - this allowed validation messages on compulsory fields to
> appear only after the user attempted data entry. (The empty form
> wasn't a heap of validation errors before the user started. The
> validation errors only appeared after the user had attempted data
> entry for a field.)
There is a good example of that here:
http://www.patientslikeme.com/user/signup
I like the validation error messages on blur (the username one is async to check for username already in use). The "Thank you" message on validation pass is also good, and demonstrates the untouched/invalid/valid split. The same mechanism is used on the second stage of the form to display little bar charts and pies to show you what proportion of the userbase has, for example, the same age as you.
Douglas
[2] use a text binder bound to the error observable on the extended observable for which you have configured validation
[4] bind to a ko.validation.group and render the text to screen
you could attach a jQuery behaviour or plugin to these element that renders the message as a tooltip, rather than a plain bold tag as below.
HiI've had a quick try at adding validation to a view model, that allows a fairly fluent registration and binding approach.Body <em data-bind='text: body.error()'></em> <br/>
<textarea data-bind='value: body'></textarea> <br/>viewModel.validation
.required(viewModel.subject, 'Required')
.minLength(5, viewModel.subject, 'Minimum 5 characters')
.maxLength(10, viewModel.subject, 'Maximum 10 characters');This is heavily based on a previous jsFiddle from Max Zelinski at http://jsfiddle.net/maxzelinski/GpTP3/.Hope it works! (Tested in Chrome.)Are there any other Gists/jsFiddle or other samples of good approaches?Andy