Learn backbone.js tutorial from scratch for beginners(Part 13) Model Validation in backbone.js

preview_player
Показать описание

1. validate(),
2. isValid(),
3. validationError


validate()
In model it provides rules to validate model.

isValid()
It checks that model has passed its all rules or not.

validationError
if isValid() returns false, means model contains errors, so to see those errors we use validationError.

Have a look the complete code,
[script]
initialize:function(){
},
validate:function(attribute){
return "Age should not be negative";
}

return "Name is needed";
}
}
});

var mymodel = new MyModel({
name:"Sanjay Kumar",
team:"Profotech Solutions",
age:10
});

model: mymodel,
initialize:function(){
},
render:function(){

}else{
}

}
});

var myViewObj = new MyView();

[/script]


SOCIAL :
===============

Also you can learn Wordpress Custom
===============



Tags
===============
online web tutor,
profotech solutions,
backbone js for beginners,
backbone js tutorial for beginners in hindi,
backbone js tutorial for beginners with examples,
backbone js tutorial youtube,
backbone js tutorial video,
owt tuts,
online web tutorials,

Thanks
Online Web Tutor
Keep learning and Sharing :)
Рекомендации по теме
Комментарии
Автор

So how do we pass those validation error for the browser to display?

kimbarcelona
join shbcf.ru