我正在尝试使用as
为我的应用程序进行服务器端验证节点js查看代码
router.post('/', function(req, res, next) {
var Fullname = req.body.Fullname;
var email = req.body.email;
var rollno = req.body.rollno;
var Birthdate = req.body.Birthdate;
var Gender = req.body.Gender;
var password = req.body.password;
var confirm = req.body.confirm;
req.checkBody('Fullname', 'Name is Required').notEmpty();
req.checkBody('email' , 'Email is Required').notEmpty();
req.checkBody('email' , 'Invalid Email').isEmail();
req.checkBody('rollno', 'Roll Number is Required').notEmpty();
req.checkBody('Birthdate', 'Date of Birth is Required').notEmpty();
req.checkBody('Gender' , 'Gender is Required').notEmpty();
req.checkBody('password' , 'Password is Required').notEmpty();
req.checkBody('confirm' , 'Password not Matched').equals(req.body.password);
var errors = req.validationErrors();
if (errors) {
res.render('/signup' , {
errors : errors
});
}
else {
console.log('No Errors');
}});
EJS就像
<% if(errors){ %>
<% errors.forEach(function(msg) { %>
<div class="alert alert danger"><% msg %></div>
<% }); %>
<% } %>
当我尝试获取/注册哪个是在其他路由文件中指定的get方法时,其输出ejs代码在浏览器中有错误未定义消息???