March 2, 2024 5:02 am

How to create Password Strength checker in jQuery

This tutorial show you how to create password strength checker and its very important for your website to have some password checking on signup pages to force your users to enter a strong password. This example shows you five stages of password strength very weak, weak, medium, strong and very strong all calculated on your passwords characters and its length.

How to create Password Strength checker in jQuery

[wpdm_file id=68]DEMO

If you want to make a very strong password then you have add minimum 13 digit contain numbers, latter, signs and capital latter then it will be a good and secure password.

To perform this implementation there is many plugins in jQuery but as we have to give you an easiest  solution so I have found this plugin pwdMeter and used this plugin.

jQuery and pwdMeter include:

<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="jquery.pwdMeter.js"></script>

jQuery to fire a call to plugin:

<script type="text/javascript">
$(document).ready(function(){

        $("#password").pwdMeter();

    });
</script>

This code call .pwdMeter(); function on document ready trigger.

HTML Code:

<div id="grid">
  <input type="password" id="password">
  <span id="pwdMeter" class="neutral"></span>
</div>

It will show textbox to enter password and when you enter something in password box it shows you strength in empty span.

CSS Used:

<style>
.veryweak{
color:#B40404;
}

.weak{
color:#DF7401;
}

.medium{
color:#FFFF00;
}

.strong{
color:#9AFE2E;
}

.verystrong{
color:#0B610B;
}
</style>

In CSS we have few classes on password strength change we append class to change color of text.

Final Code all together:

Complete password strength checker

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>How to create Password Strength checker in jQuery | PGPGang.com</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <script type="text/javascript" src="jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="jquery.pwdMeter.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){

                $("#password").pwdMeter();

            });
    </script>
    <style>
        .veryweak{
            color:#B40404;
        }
        .weak{
            color:#DF7401;
        }
        .medium{
            color:#FFFF00;
        }
        .strong{
            color:#9AFE2E;
        }
        .verystrong{
            color:#0B610B;
        }
    </style>
  </head>
  <body>
    <h2>How to create Password Strength checker in jQuery example.&nbsp;&nbsp;&nbsp; <a href="https://www.phpgang.com/">Home</a> | <a href="http://demo.phpgang.com/">More Demos</a></h2>
    <div style="margin-left:auto;margin-right:auto; width:260px;"><input type="password" id="password" />&nbsp;
    <span id="pwdMeter" class="neutral"></span></div><br />
  </body>
</html>
[wpdm_file id=68]DEMO

I hope you like this tutorial please write down your reviews in comments.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:

2 responses to “How to create Password Strength checker in jQuery”

  1. Rıza Han Yılmaz says:

    Thank you for this very nice project.

Leave a Reply

Your email address will not be published. Required fields are marked *