Oct 22, 2014

Password and Retype Password Validation Using JQuery

Following code will help you to validate the password and retype password.Simply you can do it using jquery, rather than writing huge java script code. In the following example when you entering password it will clear the retype password text. When you entering the text for retype password field it will call the checkPasswordMatch() function to validate the password and retype password.







<html>
   <head>
      <title>Easy Code Stuff - Password & Retype Password Validation Using JQuery</title>
      <script type="text/javascript" src="jquery.js"></script>
      <script>
         function clearRetypePassword(){
    $("#repassword").css("border","2px solid #C58917");
    $("#errorspan").css("color","#C58917");
    $("#errorspan").html("Retype The Password");
         }
  
         function checkPasswordMatch()
         {
            if($("#password").val() == $("#repassword").val()){
       $("#repassword").css("border","2px solid #41A317");
       $("#errorspan").css("color","#41A317");
       $("#errorspan").html("Passwords Match!");
            }else{
       $("#repassword").css("border","2px solid #FF2400");
       $("#errorspan").css("color","#FF2400");
       $("#errorspan").html("Passwords Does Not Match!");
            }
         }
      </script>
   </head>
   <body>
      <label for="password">Password : </label>
      <input type="password" id="password" onkeyup="clearRetypePassword(); return false;"><br/>
      <label for="repassword">Retype Password : </label>
      <input type="password" id="repassword" onkeyup="checkPasswordMatch(); return false;">
      <span id="errorspan"></span>
   </body>
</html>



No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...