title: Node.js (Express) Form Clears on Submission
body: <p>I am working on a really basic registration form in Node.js (with Express), and I am trying to find the easiest way to provide basic form validation. I've gone with "Express-Validator", which seems to do a fine job. However, my goal is to simply show any validation messages that are required and to <strong>leave the values entered by the user alone.</strong></p>
  
  <p>It seems that the request information is not making it back into the res.render, which I guess makes sense. However, I've looked everywhere I can think of and I can't find any reference that discusses how to keep form fields populated after showing error messages.</p>
  
  <p>Below is a small snippet describing my approach:</p>
  
  <pre><code>post: function(req, res){
  
              var userName = req.body.username;
              var password = req.body.password;
  
              //Validate input
              req.assert("username", 'Invalid email address.').isEmail();
              req.assert("password", 'Password cannot be empty.').notEmpty();
              req.assert("passwordConfirm", 'Passwords entered do not match!').equals(password);
  
              //Make sure we have no validation errors
              var pageErrors = req.validationErrors();
              if(!pageErrors)
              {
                  userModel.CreateUser(userName, password, function(err){
                      if(err)
                      {
                          //there was a problem inserting new user... probably already exists
                          //will need to check the error to confirm
                          var dbErrorMessage = "Could not insert record into database!";
                          if(err.code === 11000)
                          {
                              //this is a duplicate entry
                              dbErrorMessage = "A user with that email address already exists!";
                          }
  
                          res.render('register.html', { pageErrors: [{msg: dbErrorMessage }]});
                      }
                      else
                      {
                          res.render('register.html', { successMessage: successMessage });
                      }
                  });
              }
              else
              {
                  res.render('register.html', { pageErrors: pageErrors });
              }
  </code></pre>