How To Check Password Strength Using JQuery
Tags: javascript, jquery, password, validation
Published: 2021-12-17 03:03:44

In this article I will give you example of how to check password strength using jquery, here I will check whether password strength is fulfill min character requirment or not. jquery validate password strength and password strength validation.

Password is most imporatant part of authentication many times you can see error message like enter valid password or password must be atleast 6 character etc. For cross varification or double checking of enter password by user is correct or not I will give you small piece of code for check password strength in jquery or  check password size using javascript.

So, let's start to see  how to check password strength in jquery.

```
<html>
<body>
    <head>
      <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
        <title>How To Check Password Strength In jQuery - techsolutionstuff.com</title>
        <style>            
            #password-strength-status {
                padding: 5px 10px;
                color: #FFFFFF;
                border-radius: 4px;
                margin-top: 5px;
            }

            .medium-password {
                background-color: #b7d60a;
                border: #BBB418 1px solid;
            }

            .weak-password {
                background-color: #ce1d14;
                border: #AA4502 1px solid;
            }

            .strong-password {
                background-color: #12CC1A;
                border: #0FA015 1px solid;
            }
        </style>        
    </head>
    <div class="row">
      <div class="col-md-6 col-md-offset-3"><br>
          <h3>How To Check Password Strength In jQuery - techsolutionstuff.com</h3><br/>        
            <label>Password:</label>
            <input type="password" name="password" id="password" class="form-control"/>
            <div id="password-strength-status"></div>        
      </div>
    </div>    
</body>
</html>
<script>
$(document).ready(function () {
  $("#password").on('keyup', function(){
    var number = /([0-9])/;
    var alphabets = /([a-zA-Z])/;
    var special_characters = /([~,!,@,#,$,%,^,&,*,-,_,+,=,?,>,<])/;
    if ($('#password').val().length < 6) {
        $('#password-strength-status').removeClass();
        $('#password-strength-status').addClass('weak-password');
        $('#password-strength-status').html("Weak (should be atleast 6 characters.)");
    } else {
        if ($('#password').val().match(number) && $('#password').val().match(alphabets) && $('#password').val().match(special_characters)) {
            $('#password-strength-status').removeClass();
            $('#password-strength-status').addClass('strong-password');
            $('#password-strength-status').html("Strong");
        } else {
            $('#password-strength-status').removeClass();
            $('#password-strength-status').addClass('medium-password');
            $('#password-strength-status').html("Medium (should include alphabets, numbers and special characters or some combination.)");
        }
    }
  });
}); 
</script>
```
 
---

> **_[Read More : How To Validate Password And Confirm Password Using JQuery](https://techsolutionstuff.com/post/how-to-validate-password-and-confirm-password-using-jquery)_**

--- 

And finally you will get output like below screen print.

![how_to_check_password_strength_in_jquery](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98i0gtusdpe84f8arz4q.jpg)


You might also like :

- **_[Read Also : Laravel REST API CRUD Tutorial](https://techsolutionstuff.com/post/laravel-rest-api-crud-tutorial)_**

- **_[Read Also : How To Hide Toolbar In Summernote Editor](https://techsolutionstuff.com/post/how-to-hide-toolbar-in-summernote-editor)_**

- **_[Read Also : How To Integrate Paypal Payment Gateway In Laravel 8](https://techsolutionstuff.com/post/how-to-integrate-paypal-payment-gateway-in-laravel-8)_**