I am using knockout.js in my ASP.NET MVC project. I figured out how to display a form, serialise a JSON object, and display data with the help of following link: How to use knockout.js with ASP.NET MVC ViewModels?
But I am not able to figure out how to validate the form. What is the best solution to validate the form?
I have used he Knockout.Validation plugin ( https://github.com/Knockout-Contrib/Knockout-Validation ) which has worked well. It uses extenders in Knockout so you can extend the model properties to include rules like required, min, max, or pattern matches. You can also create custom rules. I created one for a url, for example. It has some built in rule for things like email, too. All of this is in the github page in the docs. It has everything you need to get started.
Another option is to use jquery validation, which also works well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With