Book Image

Knockout.JS Essentials

Book Image

Knockout.JS Essentials

Overview of this book

Table of Contents (16 chapters)
KnockoutJS Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Validating data


Now you can send and receive data, but what happens if the user sets some data that is not allowed on the server? You have no control over user input. It is important that if some values are not allowed, you alert the user to it. To validate Knockout data, there is a library called Knockout Validation (which can be found at https://github.com/Knockout-Contrib/Knockout-Validation) that makes this very easy.

This library extends the observables with some values that allow you to validate the data when it changes. We are now going to update our models to add some kind of validation.