Password strength checking with JavaScript

Posted by Hariinakoti under JavaScript category on | Points: 40 | Views : 1524
Password is most important for any powerful and secure system for authentication.Instead of using Password check on server side we can check password strength on client browser is more preferable.That's why I have create this function for the same.

function checkPassword(varFieldName) {
var password = document.getElementById(varFieldName).value;
if (document.getElementById(varFieldName).readOnly == false) {

if (password.length > 0) {
var valid = password.length >= 8 && hasUpperCaseCharacter(password) && hasLowerCaseCharacter(password) && hasNumericCharacter(password);
if (!valid) {
alert("Password must be at least 8 characters and must contain an upper case character, a lower case character and a numeric character, Password also must not be one of your last Five password.");
return valid;

using javscript function:

<asp:TextBox ID="txtName" runat="server" onblur="checkPassword(this);"></asp:TextBox>

This code found from google.

Comments or Responses

Login to post response