title: How to validate password and confirm password using jquery
body: <p>Hi i have to validate password and confirm password, my constraint is when ever i visit a page confirm password textbox should be disabled,</p>
  
  <p>when i click on submit required message only for password field it should not validate the confirm password ,</p>
  
  <p>when i entered right password in my password field then only confirm password field should be enabled </p>
  
  <p>right password means it should contain at leaset 8 characters in that 1 upper case letter,1 lower case letter,1 number,<strong>1 special character</strong></p>
  
  <p>after entered confirm password and click on check should validate both are same </p>
  
  <pre><code>  &lt;form id="formCheckPassword"&gt;
          &lt;input type="password"  name="password" id="password"/&gt;
          &lt;p id="passerror"&gt;&lt;/p&gt;    
          &lt;br&gt;
          &lt;input type="password"  name="cfmPassword" id="cfmPassword" disabled /&gt;&lt;br&gt;
          &lt;input type="submit" value="submit" id="s"/&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>Jquery</p>
  
  <pre><code>  $(document).ready(function() {
                  $("#s").click(function(event) {
            var passerror = "";
            var pass =  $.trim($("#password").val());
            if (pass == "") {
                          passerror = "pass is required";
                          $("#passerror").html(passerror);
                          $("#passerror").show();
                          event.preventDefault();
                      } 
              if(pass!= cfmPassword)
              {
               display error message
  
              }
              else
              {
  
              }
         });
  
        $("#password").focusout(function(){
            var pwd=$("#password").val();
                  var errorMessage = "";
                      function isValidPassword(emailAddress) {
                        var pattern = new RegExp(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/);
                        return pattern.test(emailAddress);
                      };
                      if (!isValidPassword(pwd.val())) {
                        errorMessage = "&lt;br /&gt;Please enter a valid email address";
                        $("#error").html(errorMessage);
                        $( "#error" ).show();
                        event.preventDefault();
  
                      }
  
          });     
              });
  </code></pre>
  
  <p><strong>css</strong></p>
  
  <pre><code>  #passerror{  
          color: red;
      }
  </code></pre>
  
  <p>Can anyone update the code</p>
  
  <p><a href="http://jsfiddle.net/BSdc8/285/" rel="nofollow noreferrer">http://jsfiddle.net/BSdc8/285/</a></p>