title: Document is not defined
body: <p>I have been trying to implement a login functionality for this website that I am creating. I am able to check whether the user is in the database or not. However, if the user is not in the database I would like to display a message in the form that says; "user not found." I am trying to use jQuery, but I keep getting the "Document not defined" error.</p>
  
  <p>Code in my js file looks like: </p>
  
  <pre><code>router.post('/login', function(req, res) {
      passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err) }
          if (!user) {
              req.flash('error', info.message);
                  $(document).ready(function() {
                      $("#label1").text("Hello world!");
                      $("#label1").css('color', 'red');
                  });
                  return res.redirect('/nouser')//called when no user found. to implement
          }
                      req.logIn(user, function(err) {
                          if (err) { return next(err); }
                          res.redirect(req.session.returnTo || '/');
                      });
          })(req, res);
  });
  </code></pre>
  
  <p>My form is:</p>
  
  <pre><code> &lt;!-- Username &amp; Password Login form --&gt;
      &lt;div class="user_login"&gt;
          &lt;form id="login" action="/auth/login" method="post"&gt;
              &lt;label id="label1"&gt;Email&lt;/label&gt;
              &lt;input name="email" type="email" /&gt;
              &lt;br /&gt;
  
              &lt;label&gt;Password&lt;/label&gt;
              &lt;input name="password" type="password" /&gt;
              &lt;br /&gt;
  
              &lt;div class="action_btns"&gt;
                  &lt;div class="one_half"&gt;&lt;a href="#" class="btn back_btn"&gt;&lt;i class="fa fa-angle-double-left"&gt;&lt;/i&gt; Back&lt;/a&gt;&lt;/div&gt;
                   &lt;input type="submit" class="btn btn_red" value="login"&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  
          &lt;a href="#" class="forgot_password"&gt;Forgot password?&lt;/a&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>I am very new to web programming and any help would be very well appreciated.
  Thanks.</p>