0. 密码为空
1. 密码长度小于六位.或者密码只有一种组合
2. 密码长度大于五位, 且有两种组合.
3. 密码长度大于五位, 且有三种组合.
4. 密码长度大于五位, 且有四种组合.
<script language="JavaScript">
function EvaluatePassword(word)
{
if (word == "")
{
return 0;
}
else if (word.length < 6)
{
return 1;
}
else
{
return word.match(/[a-z](?![^a-z]*[a-z])|[A-Z](?![^A-Z]*[A-Z])|\d(?![^\d]*\d)|[^a-zA-Z\d](?![a-zA-Z\d]*[^a-zA-Z\d])/g).length;
}
}
var test = new Array("", "a1_", "abcdef", "abcde123", "ads23%", "aA1B2^&2");
for(var i in test)
{
document.write(test[i] + " 的密码强度为" + EvaluatePassword(test[i]) + "<br>");
}
</script>
转自 http://www.cnblogs.com/0009/
1. 密码长度小于六位.或者密码只有一种组合
2. 密码长度大于五位, 且有两种组合.
3. 密码长度大于五位, 且有三种组合.
4. 密码长度大于五位, 且有四种组合.
<script language="JavaScript">
function EvaluatePassword(word)
{
if (word == "")
{
return 0;
}
else if (word.length < 6)
{
return 1;
}
else
{
return word.match(/[a-z](?![^a-z]*[a-z])|[A-Z](?![^A-Z]*[A-Z])|\d(?![^\d]*\d)|[^a-zA-Z\d](?![a-zA-Z\d]*[^a-zA-Z\d])/g).length;
}
}
var test = new Array("", "a1_", "abcdef", "abcde123", "ads23%", "aA1B2^&2");
for(var i in test)
{
document.write(test[i] + " 的密码强度为" + EvaluatePassword(test[i]) + "<br>");
}
</script>
转自 http://www.cnblogs.com/0009/