Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ReferenceError: e:2016passportviewsregister.ejs:38
- 36|
- 37| <div class="alert alert-danger">
- >> 38| <% if (errors) { %>
- 39| <h2><%= errors %></h2>
- 40| <% } %>
- 41| </div>
- errors is not defined
- at eval (eval at <anonymous> (e:2016passportnode_modulesejslibejs.js:491:12), <anonymous>:11:12)
- at returnedFn (e:2016passportnode_modulesejslibejs.js:520:17)
- at View.exports.renderFile [as engine]
- router.post('/register',function(req,resp){
- var msg;
- var name= req.body.name;
- var username= req.body.username;
- var email= req.body.email;
- var password= req.body.password;
- var password2= req.body.password2;
- console.log('name ' + password + " email" + email);
- // validation using express validator
- req.checkBody("name"," the name filed should be there").notEmpty();
- req.checkBody("username","username is required").notEmpty();
- req.checkBody("email","email is required").isEmail().notEmpty();
- req.checkBody("password","password is required").notEmpty();
- req.checkBody("password2","passwords is NOT match ").equals(password);
- // collect all errors there
- var errors=req.validationErrors();
- //Check the errors
- if(!errors && errors.length <=0){
- console.log(' No errors errors :: ' +errors.length );
- }
- // if there is errors display them to users
- else{
- console.log("errors: "+ errors.length + JSON.stringify(errors));
- // now you pass data from router to view
- resp.render('register',{errors:errors});
- }
- });
- <pre>
- <div>
- <P>Register</P>
- <div class="alert alert-danger">
- <% if (errors) { %>
- <h2><%= errors %></h2>
- <% } %>
- </div>
- </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement