Test Password Strength using Javascript and Jquery | Sanwebcorner

Test Password Strength using Javascript and Jquery

Today i am going to tell you how to test password strength in password textbox field using Jquery. This concept will done by using simple javascript, This is one of the important concept in any forms because the password field is very important field using this password only clients they access their account so you can set this password securly, So you can set strong password with combination of letters and numbers and special characters.

Create javascript function keyup, The keyup event occurs when a keyboard key is released. The password strength message will show when key up. In javascript will write some of the condition and display the message based on those conditions. First is if the password strength is less then six characters the message is Too Short will display. Grater then six character without numbers and special character it shows weak password. If the number of characters seven and special char it shows good and then finally morethen seven char with numbers and special characters it shows strong password.You also validate the password field using password strength. So it gives the secure password to the user.

This concept is one of the userfriendly because user knows we are created password is secure or not when they fill the form itself. Below example shows to check the password strength with the help of javascript. It haves the live example and codes for your reference, I hope this post is really helpful.

Check Password strength using Jquery:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>How to check password strength using jQuery</title>
<!--jQuery Library-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
font-size: 15px;
line-height: 1.5;
font-family: 'Roboto', sans-serif;


h2{ text-align:center; color:#fff;}

margin:50px auto;
border: 1px solid #7F7F7F;


#password-strength label{
#password-strength input {
padding:5px 7px;
border:1px solid #d5d9da;
box-shadow: 0 0 5px #e8e9eb inset;


#password-strength .short{

#password-strength .weak{

#password-strength .good{

#password-strength .strong{
function checkStrength(password)
var strength = 0
if (password.length < 6) { 
return 'Too short' 

if (password.length > 7) strength += 1
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  strength += 1
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  strength += 1 
if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/))  strength += 1
if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
if (strength < 2 )
return 'Weak'
else if (strength == 2 )
return 'Good'
return 'Strong'
<div id="container">
<h2>Password Strength Checking with jQuery</h2>
<div id="content">
<center><form id="password-strength">
<label>Password : </label>
<input name="pwd" id="pwd" type="password"/>
<span id="strength_message"></span>
<a href="http://www.sanwebcorner.com">www.sanwebcorner.com</a>

Post a comment


360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap Bootstrap form validation border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed donation form download zip email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient heart animation hide menu Horizontal News ticker Hover Htm Html html dropdown html form html form validation html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript javascript validation Jquery jquery validation js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form multi-select-checkbox Multi-Step-form Multiple File Upload in PHP mysql News ticker on hover change text to image our team page password generator password strength checker paypal form paypal html form Photoshop PHP php mailer populate html selectbox Popup image on click the link pure css Question type form random number generate Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image selectbox based on select box simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips whatsapp link website Whislist Youtube