This is what I did some time back. A simple point based approach.
function CheckPassword()
{
var password = document.getElementById('<%=txtPassword.ClientID %>').value;
var txtPassword = document.getElementById('<%=lblPasswordMeter.ClientID %>');
var score = 0;
if(password.length < 8)
{
txtPassword.style.color = "Red";
txtPassword.innerHTML = "Too short";
return;
}
for(var s=0; s<password.length; ++s)
{
if(password.charCodeAt(s) >= 'a'.charCodeAt(0) && password.charCodeAt(s) <= 'z'.charCodeAt(0))
{
score += 1;
break;
}
}
for(var s=0; s<password.length; ++s)
{
if(password.charCodeAt(s) >= 'A'.charCodeAt(0) && password.charCodeAt(s) <= 'Z'.charCodeAt(0))
{
score += 1;
break;
}
}
for(var s=0; s<password.length; ++s)
{
if(password.charCodeAt(s) >= '0'.charCodeAt(0) && password.charCodeAt(s) <= '9'.charCodeAt(0))
{
score += 1;
break;
}
}
switch(score)
{
case 0:
case 1:
txtPassword.style.color = "Red";
txtPassword.innerHTML = "too weak";
break;
case 2:
txtPassword.style.color = "Orange";
txtPassword.innerHTML = "average";
break;
case 3:
txtPassword.style.color = "Green";
txtPassword.innerHTML = "strong";
break;
}
};