我是HTML和Javascript的新手。我的目标是建立一个密码检查器。我使用此链接http://curiositybeyondcontrol.blogspot.ie/2012/04/password-strength-indication-using.html中的代码作为以下给定代码的基础。当我运行原始它运行正常。但是当我运行我的版本时,它一直在说“检查”。功能未定义。 请指导我在哪里更正此代码。
请找到我的代码:
<html>
<head>
<title>Password strength</title>
<script type="text/javascript">
function check(x)
{
var pstring = String(x);
var level = 0;
var plength = pstring.length;
var p1 = /[a-z]/;
var p2 = /[A-Z]/;
var p3 = /[0-9]/;
var p4 = /[\!\@\#\$\%\^\&\*\(\)\-\_\=\+\[\{\]\}\|\\\;\:\'\"\,\<\.\>\/\?\`\~]/;
if(p1.test(x))
level++;
if(p2.test(x))
level++;
if(p3.test(x))
level++;
if(p4.test(x))
level++;
prog_bar(plength,level,200,5,"#0066FF","#99FFFF");
}
function prog_bar(pass_length,pass_level,width,height,border,fill)
{
var str = "",numdays = 0;
if(pass_length = 1 && pass_level = 1)
numdays = 0;
else if(pass_length = 1 && pass_level = 2)
numdays = 0;
else if(pass_length = 1 && pass_level = 3)
numdays = 0;
else if(pass_length = 1 && pass_level = 4)
numdays = 0;
else if(pass_length = 2 && pass_level = 1)
numdays = 0;
else if(pass_length = 2 && pass_level = 2)
numdays = 0;
else if(pass_length = 2 && pass_level = 3)
numdays = 0;
else if(pass_length = 2 && pass_level = 4)
numdays = 0;
else if(pass_length = 3 && pass_level = 1)
numdays = 0;
else if(pass_length = 3 && pass_level = 2)
numdays = 0;
else if(pass_length = 3 && pass_level = 3)
numdays = 0;
else if(pass_length = 3 && pass_level = 4)
numdays = 0;
else if(pass_length = 4 && pass_level = 1)
numdays = 0;
else if(pass_length = 4 && pass_level = 2)
numdays = 0;
else if(pass_length = 4 && pass_level = 3)
numdays = 0;
else if(pass_length = 4 && pass_level = 4)
numdays = 0;
else if(pass_length = 5 && pass_level = 1)
numdays = 0;
else if(pass_length = 5 && pass_level = 2)
numdays = 0;
else if(pass_length = 5 && pass_level = 3)
numdays = 0;
else if(pass_length = 5 && pass_level = 4)
numdays = 0;
else if(pass_length = 6 && pass_level = 1)
numdays = 0;
else if(pass_length = 6 && pass_level = 2)
numdays = 0;
else if(pass_length = 6 && pass_level = 3)
numdays = 0;
else if(pass_length = 6 && pass_level = 4)
numdays = 0;
else if(pass_length = 7 && pass_level = 1)
numdays = 0;
else if(pass_length = 7 && pass_level = 2)
numdays = 0;
else if(pass_length = 7 && pass_level = 3)
numdays = 0;
else if(pass_length = 7 && pass_level = 4)
numdays = 0;
else if(pass_length = 8 && pass_level = 1)
numdays = 0;
else if(pass_length = 8 && pass_level = 2)
numdays = 0;
else if(pass_length = 8 && pass_level = 3)
numdays = 0;
else if(pass_length = 8 && pass_level = 4)
numdays = 0;
else if(pass_length = 9 && pass_level = 1)
numdays = 0;
else if(pass_length = 9 && pass_level = 2)
numdays = 0;
else if(pass_length = 9 && pass_level = 3)
numdays = 0;
else if(pass_length = 9 && pass_level = 4)
numdays = 1;
else if(pass_length = 10 && pass_level = 1)
numdays = 0;
else if(pass_length = 10 && pass_level = 2)
numdays = 0;
else if(pass_length = 10 && pass_level = 3)
numdays = 1;
else if(pass_length = 10 && pass_level = 4)
numdays = 70;
else if(pass_length = 11 && pass_level = 1)
numdays = 0;
else if(pass_length = 11 && pass_level = 2)
numdays = 11;
else if(pass_length = 11 && pass_level = 3)
numdays = 75;
else if(pass_length = 11 && pass_level = 4)
numdays = 6512;
else if(pass_length = 12 && pass_level = 1)
numdays = 0;
else if(pass_length = 12 && pass_level = 2)
numdays = 11;
else if(pass_length = 12 && pass_level = 3)
numdays = 75;
else if(pass_length = 12 && pass_level = 4)
numdays = 6512;
else if(pass_length = 13 && pass_level = 1)
numdays = 4;
else if(pass_length = 13 && pass_level = 2)
numdays = 29406;
else if(pass_length = 13 && pass_level = 3)
numdays = 289393;
else if(pass_length = 13 && pass_level = 4)
numdays = 56321550;
else if(pass_length = 14 && pass_level = 1)
numdays = 93;
else if(pass_length = 14 && pass_level = 2)
numdays = 1529125;
else if(pass_length = 14 && pass_level = 3)
numdays = 17942375;
else if(pass_length = 14 && pass_level = 4)
numdays = 5237904191;
else if(pass_length = 15 && pass_level = 1)
numdays = 2427;
else if(pass_length = 15 && pass_level = 2)
numdays = 79514517;
else if(pass_length = 15 && pass_level = 3)
numdays = 1112427235;
else if(pass_length = 15 && pass_level = 4)
numdays = 487125089774;
else if(pass_length = 16 && pass_level = 1)
numdays = 63091;
else if(pass_length = 16 && pass_level = 2)
numdays = 4134754882;
else if(pass_length = 16 && pass_level = 3)
numdays = 68970488580;
else
numdays = 45302633348959;
if(numdays<=11)
fill = "#FF0000";
else if(numdays<=600)
fill = "#FFFF00";
else
fill = "#00FF00";
str = str + "<div style=\"border:"+border+" solid thin; width:"+width+"px; height:"+height+"px;\">";
str = str + "<div style=\"background-color:"+fill+"; width:"+res+"%; height:"+height+"px;\">";
str = str + "</div></div>";
if(numdays<=11)
str = str + "Easy";
else if(numdays<=600)
str = str + "A Bit Tough";
else
str = str + "Unbreakable";
document.getElementById("prog_bar").innerHTML = str;
}
</script>
</head>
<body>
This password checker checks the strength of your password as well as
<br />the number of days a hacker would take to break your password<br /><br />
Password : <input type="password" onkeyup="check(this.value)" /><br /><br />
<div id="prog_bar"></div>
</body>
</html>
提前谢谢