O'Reilly logo

Mastering Backbone.js by Abiee Echamea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validating model data

Usually, on frontend applications, the inputs are validated with UI plugins such as jQuery Validation, which focuses on the user interface. In other words, the data is validated directly on the DOM. However, on bigger applications that would not be the best approach.

Validations in Backbone can be done manually or through plugins. Of course, the best approach is to use a plugin because it saves time and effort, but before we learn how to use the backbone.validation plugin, I want to show you how native validation works.

Manual validation

Backbone models have three properties to help us validate the model data: validate(), validationError(), and isValid(). The validate()method should return nothing if the model data is correct, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required