In many apps, it's important to validate data before sending it to the server. The jquery/model/validations plugin provides validations on models.
To use validations, you need to call a validate method on the Model class. The best place to do this is in a Class's init function.
$.Model.extend("Contact",{
init : function(){
// validates that birthday is in the future
this.validate("birthday",function(){
if(this.birthday > new Date){
return "your birthday needs to be in the past"
}
})
}
},{});
Click a person's name to update their birthday. If you put the date in the future, say the year 2525, it will report back an error.