Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. ReferenceError: e:2016passportviewsregister.ejs:38
  2. 36|
  3. 37| <div class="alert alert-danger">
  4. >> 38| <% if (errors) { %>
  5. 39| <h2><%= errors %></h2>
  6. 40| <% } %>
  7. 41| </div>
  8.  
  9. errors is not defined
  10. at eval (eval at <anonymous> (e:2016passportnode_modulesejslibejs.js:491:12), <anonymous>:11:12)
  11. at returnedFn (e:2016passportnode_modulesejslibejs.js:520:17)
  12. at View.exports.renderFile [as engine]
  13.  
  14. router.post('/register',function(req,resp){
  15. var msg;
  16. var name= req.body.name;
  17. var username= req.body.username;
  18. var email= req.body.email;
  19. var password= req.body.password;
  20. var password2= req.body.password2;
  21. console.log('name ' + password + " email" + email);
  22.  
  23. // validation using express validator
  24. req.checkBody("name"," the name filed should be there").notEmpty();
  25. req.checkBody("username","username is required").notEmpty();
  26. req.checkBody("email","email is required").isEmail().notEmpty();
  27. req.checkBody("password","password is required").notEmpty();
  28. req.checkBody("password2","passwords is NOT match ").equals(password);
  29. // collect all errors there
  30. var errors=req.validationErrors();
  31.  
  32.  
  33. //Check the errors
  34. if(!errors && errors.length <=0){
  35. console.log(' No errors errors :: ' +errors.length );
  36. }
  37. // if there is errors display them to users
  38. else{
  39. console.log("errors: "+ errors.length + JSON.stringify(errors));
  40. // now you pass data from router to view
  41. resp.render('register',{errors:errors});
  42. }
  43.  
  44. });
  45.  
  46. <pre>
  47. <div>
  48. <P>Register</P>
  49. <div class="alert alert-danger">
  50. <% if (errors) { %>
  51. <h2><%= errors %></h2>
  52. <% } %>
  53. </div>
  54. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement