I am trying to show the errors upon submitting the register form, but the errors show up in the following manner (where as each line is 1 error):
[object Object]
[object Object]
[object Object]
[object Object]
Validation code
router.post('/register', function(req, res) {
var name = req.body.name;
var email = req.body.email;
var password = req.body.password;
var password2 = req.body.password2;
// validation
req.checkBody('name', 'Name is required').notEmpty();
req.checkBody('email', 'Email is required').notEmpty();
req.checkBody('email', 'Email is not valid').isEmail();
req.checkBody('password', 'Password is required').notEmpty();
req.checkBody('password2', 'Passwords do not match').equals(req.body.password);
var errors = req.validationErrors();
if(errors) {
res.render('register', {
errors:errors
});
console.log("errors");
} else {
console.log('No validation errors');
}
});
Jade code
if errors
for each in errors
p #{each}
I don't think the code in Jade is right, but I don't know how to do it right either.
via DowinskiField
No comments:
Post a Comment