I have a search form & knockout-based grid for results. When search is performed, there is some server-side validation taking place on asp.net mvc, and if model state is not valid, it is returning list of model errors via JSON.
I have jQuery validation already set up, and default validations (regex, required etc) are automatically mapped using jquery.unobtrusive plugin.
I found $.validate().showErrors({prop:error}) as a way to dynamically show errors based on json response from server, but I'm thinking that this is not proper way to use it for displaying server validation messages, as field cannot be reset afterwards (input-validation-error class is not removed).
I need a working method for setting & resetting errors on client, if such exists in $.validate.
There is example with my problem on jsFiddle: http://jsfiddle.net/goranobradovic/ughCm/
To reproduce it, click add error, then remove error, input stays red.
This is because showErrors function does not add any rules which are triggered by validation, so field stays 'valid' and it is not in elements() list which is used in resetForm to remove input-validation-error class from invalid fields.
Basically, I want simple way to add/remove validation rule with custom message which is never satisfied on client, to avoid form submission when I set error manually and having to remove invalid class after removing error message.