title: jQuery submit callback not working
body: <p>It's been a day since I have been trying to figure out why my form validation is not working. From my side, every part of the code is good. Basically, I am trying to verify if the two passwords entered by the user match while creating an account. If yes, the POST method is run. If not, an alert is displayed.
  But when I run it, nothing is validated, in both the cases (matching password or not).</p>
  
  <p>Need a possible reason behind the code not working.
  Here is the code:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;h2&gt;Hi! Welcome to our JCLOUD File Sharing Service. Please singup to start uploading files&lt;/h2&gt;
      &lt;/div&gt;
      &lt;div class="row" id="signup-row"&gt;
          &lt;div class="col-xs-12 col-sm-12 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4"&gt;
              &lt;h3&gt;JCloud File Sharing - Signup &lt;small&gt;&lt;/small&gt;&lt;/h3&gt;
              &lt;hr&gt;
  
              &lt;form action="register" method="post" id="signup-form"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="username"&gt;Enter a username:&lt;/label&gt;
                      &lt;input type="text" class="form-control" name="username" /&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="email"&gt;Enter your e-mail address:&lt;/label&gt;
                      &lt;input type="email" class="form-control" name="email" /&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="password"&gt;Choose a password:&lt;/label&gt;
                      &lt;input type="password" class="form-control" name="password" id="password-value" /&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="password2"&gt;Confirm password:&lt;/label&gt;
                      &lt;input type="password" class="form-control" name="password2" id="password-value2" /&gt;
                  &lt;/div&gt;
                  &lt;button type="submit" class="btn btn-primary btn-block"&gt;Create Account&lt;/button&gt;
  
              &lt;/form&gt;
              &lt;p&gt;${requestScope["message"]}&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
          &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt;
          &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"&gt;&lt;/script&gt;
          &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"&gt;&lt;/script&gt;
  
          &lt;script&gt;
  
              $('#signup-form').submit(function() {
  
                  var pass1 = $("#password-value").val();
                  var pass2 = $("#password-value2").val();
  
                  if( pass1 == pass2 ) {
                      var encrypted = CryptoJS.SHA256($("#password-value").val());
                      $("#password-value").val(encrypted);
  
                      var encrypted2 = CryptoJS.SHA256($("#password-value2").val());
                      $("#password-value2").val(encrypted2);
  
                      return true;
                  }
  
                  else{
  
                      $("#signup-row").before("&lt;div class='row'&gt;" +
                          "&lt;div class='col-xs-12 col-sm-12 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4'&gt;" +
                          "&lt;div class="alert alert-danger"&gt;&lt;strong&gt;Error!&lt;/strong&gt; The passwords you entered don not match." +
                      "&lt;/div&gt;" +
                          "&lt;div&gt;" +
                          "&lt;/div&gt; ");
  
                      return false;
  
                  }
              });
  
          &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>