Password strength checker is very important for your signup form. It let’s you know the intensity of your password, whether it is weak or strong. If it is weak, you need to modify and make it stronger.

In this example you will learn how to create a strength checker in jQuery with four stages of strength – “Too short, Weak, Good, Strong” init. That enables anyone to choose it with high authority and relevancy..

Remember, a strong password is unbreakable and untraceable.


Before starting with the codes, I want to tell you some basic conditions that calculates the password strength. They are:

  • Length.
  • Use of special Characters like, [@, $].
  • Use of uppercase [A – Z] and lowercase [a – z] letters.
  • Use of numbers [0 – 9].

For a strong password, you need to take care including special characters along with your regular words.

Below is our complete code that contains HTML,jQuery and CSS file.

HTML File – passwordscheck.html

<title>Password strength checker in jQuery</title>
<link href='|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>
<script src=""></script><!-- jQuery Library-->
<link rel="stylesheet" href="css/passwordscheck.css" /><!-- Include Your CSS file here-->
<script src="js/passwordscheck.js"></script><!-- Include Your jQUery file here-->
<div id="container">
<div id="header">
<h2>Password Strength Checking with jQuery</h2>
<div id="content">
<form id="register">
<label for="password"><b>Password : </b></label>
<input name="password" id="password" type="password" placeholder="Type Your Password here"/>&nbsp;&nbsp;
<span id="result"></span>

jQuery File –  passwordscheck.js

$(document).ready(function() {
$('#password').keyup(function() {
function checkStrength(password) {
var strength = 0
if (password.length < 6) {
return 'Too short'
if (password.length > 7) strength += 1
// If password contains both lower and uppercase characters, increase strength value.
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) strength += 1
// If it has numbers and characters, increase strength value.
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) strength += 1
// If it has one special character, increase strength value.
if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
// If it has two special characters, increase strength value.
if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
// Calculated strength value, we can return messages
// If value is less than 2
if (strength < 2) {
return 'Weak'
} else if (strength == 2) {
return 'Good'
} else {
return 'Strong'

CSS File – passwordscheck.css

margin: 0;
padding: 0;
font-family: 'Raleway', sans-serif;
font-size: 15px;
line-height: 1.5;
#container {
width: 535px;
background: #ffffff;
padding: 20px;
margin: 90px auto;
border-radius: 5px;
height: 150px;
border: 2px solid gray;
#header {
text-align: center;
background-color: #FEFFED;
border-radius: 5px;
margin: -39px -20px 10px -20px;
padding-top: 10px;
#content {
margin-left: 57px;
margin-top: 40px;
#register label{
#register input {
padding: 5px 14px;
border: 1px solid #d5d9da;
box-shadow: 0 0 9px #0E34F5 inset;
width: 272px;
font-size: 1em;
height: 25px;
#register .short{
#register .weak{
#register .good{
#register .strong{
color: limegreen;


If you don’t want hackers to crack your password, give a strong one. And, if you want to know whether your password is strong or not, use password strength checker in your form.

So that, you yourself and the users who will register on your signup form will feel relaxed when they see a “strong” strength of their password.

Recommended blogs –