Question 1
I'm trying to add a form validation using the following link.
https://github.com/gfranko/Backbone.validateAll/blob/master/demos/index.html
The sample code is working perfectly. But in my case I have a form with corresponding View, when I click on the submit button how can I validate?
In my View's initialize() I have added the following code to enable validation for the fields.
var user = new User;
$('input').each(function() {
new Field({el: this, model: user});
});
this.model.set({route: formData.route}, {validate: true, validateAll: false});
But it is not validating.
My idea is validate a form with backbone and submit to PHP.
Using the code in the link how can I achieve it?
Question 2
I tried some other kind fo validations, Model save() error callback is not working for it.
this.model.save({route:formData.route}, {
error: function(){
console.log('error!!!'); // Not showing for failed validation
},
success: function(){
console.log('success!!!!!');
}
});
What could be the reason?