I try to use KnockoutJs validation plugin and I have a problem. Before post data from input I validate the value, if it is correct I post it and reset my viewmodel to the default state, if value isn't correct I wrap the input into the red border by adding some css class (or add error message). The problem is that this works only once: after post data I reset my viewmodel to the default state (as I said before), the input field becomes empty and if I try to post this empty data, validation works, but css class doesn't apply (error message doesn't appear). Please try my Fiddle example, what's wrong ?
* [Update].
So, I found workaround: just add additional code to data-bind attribute
validationElement: itemToAdd().Name
it should be
<input data-bind='value: itemToAdd().Name, validationElement: itemToAdd().Name' />
It works, but looks bad. Anyway, it will be good, if someone can fix my previous code.