Welcome aboard! We are happy you are here and wish you good net-raft!
<script type="text/javascript"> 
var Rank = Backbone.Model.extend({
defaults: {
lang: 'backbone.js',
rank: 3,
},
initialize : function(){
this.on("invalid",function(model,error){
document.write(error);
});
},
validate: function(attributes) {
if ( attributes.rank > 3 ) {
return 'Your rank is grater than 3!';
}
if ( attributes.rank < 3 ) {
return 'Your rank is less than 3!';
}
if ( ! attributes.lang ) {
return 'please enter the language name!!!';
}
},
});
var rank = new Rank();
rank.on('invalid', function() {
this.arguments;
});
rank.set({ rank : 4}, { validate : true }); 
</script> 
result: Your rank is grater than 3! 
The most helpful BACKBONE.JS solutions
How to get country from client ip address using backbonejs ?BACKBONE.JS
Click to see more ...
1.1K
84
How to bind callback to only fire once before being removed using backbone.js ?BACKBONE.JS
Click to see more ...
803
66
How to detect the type of a device using backbonejs ?BACKBONE.JS
Click to see more ...
705
59
How to detect the version of IE browser using backbonejs ?BACKBONE.JS
Click to see more ...
538
53
How to detect mobile device not tablet using backbonejs ?BACKBONE.JS
Click to see more ...
553
51
How to get clients latitude and longitude from ip address using backbonejs ?BACKBONE.JS
Click to see more ...
587
48
How can I trigger a fucntion using backbone.js ?BACKBONE.JS
Click to see more ...
397
46
How can I trigger a function in backbone.sj?BACKBONE.JS
Click to see more ...
675
44
How can I trigger multiple functions using backbone.js ?BACKBONE.JS
Click to see more ...
486
39
How set and get a value in backbone.js ?BACKBONE.JS
Click to see more ...
362
36