title: Validation on old password field
body: <p>Stucked how to apply validation if old password not entered. Need validation if anyhow user forgot to enter the old password. Thanks in advance.</p>
  
  <p><a href="http://jsfiddle.net/adampavlov/hqtbfo8k/2/" rel="nofollow noreferrer">FIDDLE DEMO</a></p>
  
  <pre><code>$(document).ready(function() {
            $("#submitBtn").click(function(){
                validate();
            });
          });
  
          function validate() {
            var password1 = $("#password1").val();
            var password2 = $("#password2").val();
              if(password1 != password2) {
                 $(".error-msg").html("Password and confirmation password do not match.").show();                    
              }
              else {
                  $(".error-msg").html("").hide();  
                  ValidatePassword();
              }
          }
  
          function ValidatePassword() {
            var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&amp;*?])[A-Za-z\d#$@!%&amp;*?]{8,}$/;
            var txt = document.getElementById("password1");
            if (!regex.test(txt.value)) {
                $(".error-msg").html("The password does not meet the password policy requirements.").show();
            } else {
                $(".error-msg").html("").hide();
                window.location.href='change-password-msg.html';
            }
          }
  </code></pre>