Display errors using Knockout JS + MVC + Server-side Model Validation? Display errors using Knockout JS + MVC + Server-side Model Validation? json json

Display errors using Knockout JS + MVC + Server-side Model Validation?


There's two validation plugins for ko.js (found here) that could help you,

Knock-Knock validation

Knockout Validation

You can wire one of those to the mvc unobstrsive validation data injected client side.


If you are using MVC, unobtrusive javascript performs client side validation based on the validation set in your model. You need not perform any additional configuration.

Having said that, there is no direct way to perform client side validation based on the model using javascript and knockoutjs.

There are couple of ways of doing it on the client side.

  1. Jquery or any other validation frameworks can perform validation. But you need to have tag. Advantage with this approach is your code will be simple and easy to maintain.
  2. You can perform client side custom validation using javascript and bind the validation messages using knockout. This requires you to create error labels for each of the input variable. Advantage with this approach is you will have complete control over how and what has to be displayed.

Personally, I had similar requirement in one of the recent projects and I achieved it using custom validation checks and error labels.