求大神帮忙看看哪里有问题,验证码总是错误
<!doctype html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<script>
var chars=[];
for (var r=48;r<=57;r++)
{
chars.push(String.fromCharCode(r));
}
for (var min=97;min<=122;min++)
{
chars.push(String.fromCharCode(min));
}
for (var max=65;max<=90;max++)
{
chars.push(String.fromCharCode(max));
}
//debugger;
function getCode(){
for (var i=0,code=[];i<4;i++)
{
var r=Math.floor(Math.random()*62);
code.push(chars[r]);
}
return code.join(" ");
}
var code=getCode();
//debugger;
var input;
while((input=prompt("请输入验证码:"+code)).toUpperCase()!=code.toUpperCase()){
alert("验证码输入错误,请重新输入")
code=getCode();
}
document.write("<h3>验证码输入正确</h3>")
</script>
</body>
</html>