0
這是我的代碼:功能check()
工作,但功能ChangeCaptcha()
沒有表現出信輸入type="randomfield"
:如何在沒有php的情況下添加captcha?
<body onload="ChangeCaptcha()">
<input type="text" id="randomfield" disabled><br><br>
<input id="CaptchaEnter" size="20" ><br><br>
<button type="submit" onclick="check()">Log in</button>
<script type="text/javascript">
function ChangeCaptcha() {
var chars= "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_lenght = 6;
var ChangeCaptcha = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
ChangeCaptcha+= chars.substring(rnum, rnum+1);
}
document.getElementById('randomfield').value= ChangeCaptcha;
}
function check() {
if (document.getElementById('CaptchaEnter').value == document.getElementById('randomfield').value) {
window.open('http://www.lolila.hol.es', '_self');
} else {
alert('Pleace re-check the captcha!')
}
}
</script>
</body>
究竟什麼是您所遇到的問題?你期望得到什麼? –
你爲什麼要做客戶端驗證碼驗證?閱讀此:http://stackoverflow.com/questions/3196335/how-to-create-simple-javascript-jquery-client-side-captcha – omerowitz
錯誤的'var string_lenght = 6' >>'我
NewToJS