【发布时间】:2015-08-26 13:56:47
【问题描述】:
尝试使用快速验证来验证某些表单输入。 一切正常,但无法弄清楚如何检查相同的密码。
// 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,并为 mad englisch 感到抱歉。 如果有人需要更多信息,我很乐意提供。 谢谢
ps。 已经试过了:
req.assent('password2', 'Password do not match').equals(req.body.password);
【问题讨论】:
-
checkbody缺少大写字母 B...
标签: node.js validation express