Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use password strength indicator on slider?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 360
    Comment on it

    In this example, we used a variable named score to calculate the strength of password. If password contain 6 chars the score increases with 10 points, if it has at least one digit 10 points, has at least one ASCII symbol (!@#$%^&*) 10, mixed upper and lower case 10, perfect score = 40.The passwordStrength(pass) function calculates the score according to the value provided in the password field and makes the slider moveable by passing the value of score to the slider.

    Example:

    index.html

    <input type="text" name="password" placeholder=" enter password" id="pass"/>
    <div id="indicator">
       <input type="range" id="slider" min="0" max="40" value="0" />
       <p class="note">Current value: <span id="currentValue">0</span></p>
    </div>
    

    abc.js

     $(document).ready(function(){
          $('#pass').keyup(function(){
              passwordStrength($('#pass').val());
          });
     });
    
    function passwordStrength(pass)
     {
            var score=0;
            if(pass.length > 6)
                {score+=10;}
            if(pass.match(/(.*[0-9])/))
                {score+=10;}
            if(pass.match(/(.*[!,@,#,$,%,^,&,*,?,&#95;,~])/))
                score+=10;
            if (pass.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  
                score += 10;
            $('#slider').val(score);
            var currentValue = score;
            $('#currentValue').html(currentValue);
      }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: