Backbone.JS Validate()

The Backbone.JS Validate() model is used to validate the input before displaying the result. For invalid inputs, the Backbone.JS Validate() model returns specified error message and for the valid inputs, it just display the result.

Syntax:

Model.Validate (attributes, options)   

Parameters:
attributes: This parameter is used to specify the properties of a model.
options: This parameter is used to specify the options like id, name etc. for a model.

Example:

 

  
Example  
  
  
  
  
  
  
  
  

Output:

Enter the correct age.

Explanation:
Since we set the value of student_age less than 10, hence it returned a Validation Error message.