blog post

In this article I will explain how to implement Password Strength validation for Password jQuery. The Password strength validation in JavaScript and jQuery will be performed using Regular Expressions (Regex). The following HTML consists of an HTML Input TextBox and an HTML SPAN element. The HTML Input TextBox has been assigned a JavaScript OnKeyUp event handler which calls the CheckPasswordStrength JavaScript function. Inside the CheckPasswordStrength JavaScript function, an array of multiple Regular Expressions has been built.

Source Code

<title>Password strength
<body style="text-align:center">
Password: <input type="text" id="txtPassword" Placeholder="Password" />
<span id="password_strength"></span>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    $(function () {
        $("#txtPassword").bind("keyup", function () {
            //TextBox left blank.
            if ($(this).val().length == 0) {
            //Regular Expressions.
            var regex = new Array();
            regex.push("[A-Z]"); //Uppercase Alphabet.
            regex.push("[a-z]"); //Lowercase Alphabet.
            regex.push("[0-9]"); //Digit.
            regex.push("[$@$!%*#?&]"); //Special Character.
            var passed = 0;
            //Validate for each Regular Expression.
            for (var i = 0; i < regex.length; i++) {
                if (new RegExp(regex[i]).test($(this).val())) {
            //Validate for length of Password.
            if (passed > 2 && $(this).val().length > 8) {
            //Display status.
            var color = "";
            var strength = "";
            switch (passed) {
                case 0:
                case 1:
                    strength = "Weak";
                    color = "red";
                case 2:
                    strength = "Good";
                    color = "darkorange";
                case 3:
                case 4:
                    strength = "Strong";
                    color = "green";
                case 5:
                    strength = "Very Strong";
                    color = "darkgreen";
            $("#password_strength").css("color", color);

Password Strength validation example using jQuery
  • Share This Story

Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla

I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment


Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email


Style Switcher

Change Color

×! We use cookies to improve your user experience. More information