尝试使用快速验证验证某些表单输入。 一切工作正常,但无法弄清楚我如何检查相同的密码。快速验证密码验证(等于密码)
// form validation
req.checkBody('name', 'Name is required').notEmpty();
req.checkBody('email', 'Email is required').notEmpty();
req.checkBody('email', 'Email not valid').isEmail();
req.checkBody('username', 'username is required').notEmpty();
req.checkBody('password', 'password is required').notEmpty();
//req.checkbody('password2', 'Password do not match').equals(req.body.password);
// check for errors
var errors = req.validationErrors();
if(errors) {
res.render('register', {
errors: errors,
name: name,
email: email,
username: username,
password: password,
password2: password2
});
正如你所看到的,这工作得很好。 但使用后:
req.checkbody('password2', 'Password do not match').equals(req.body.password);
它不会工作,因为我谷歌解决这个有寿工作! 有人熟悉这个问题? 顺便说一句,刚开始学习node.js,并由疯狂englisch抱歉。 如果有人需要更多的信息,我很乐意提供。 谢谢
ps。 已经尝试过:
req.assent('password2', 'Password do not match').equals(req.body.password);
'checkbody'缺少资本2 ... – robertklep