<html>
<head>
<title>纯字验证码</title>
<meta http-equiv='content-type' content='text/html;charset=utf-8'/>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type='text/javascript'>
var code ; //Define verification code function globally
createCode() {
code = "";
var codeLength = 4;//Length of verification code
var checkCode = document.getElementById("code");
var random = new Array(0,1,2,3,4,5,6,7 ,8,9,'A','B','C','D','E','F','G','H','I','J','K',' L','M','N','O','P','Q','R','S','T','U','V','W','X' ,'Y','Z'); //random number
for(var i = 0; i < codeLength; i++) {//loop operation
var index = Math.floor(Math.random()*36);//Get the index of the random number (0~35)
code += random[index];//According to the index to get the random number and add it to the code
}
checkCode.value = code;//Assign the code value to the verification code
}
//Verify the verification code
function validate(){
var inputCode = document.getElementById("input").value.toUpperCase(); //Get the input The verification code is converted to uppercase
if(inputCode.length <= 0) { //If the length of the entered verification code is 0
alert("Please enter the verification code!"); //Then please enter the verification code
}else if( inputCode != code ) { //If the input verification code is inconsistent with the generated verification code
alert("Verification code input error!@_@"); //The verification code input error pops up
createCode();//Refresh verification code
document.getElementById("input").value = ""; //Clear the text box
}else { //When the input is correct
alert("Qualified!^-^");
}
}
</script>
<style type='text/css'>
#code{
font-family:Arial,宋体;
font-style:italic;
color:green;
border:0;
padding:2px 3px;
letter-spacing:3px;
font-weight:bolder;
}
</style>
</head>
<body onload='createCode()'>
<div>验证码:
<input type = "text" id = "input"/>
<input type="button" id="code"onclick="createCode()" style="width:60px" title='Click to change the verification code' />
<input type = "button" value = "验证" onclick = "validate()"/>
</div>
</body>
</html>
<head>
<title>纯字验证码</title>
<meta http-equiv='content-type' content='text/html;charset=utf-8'/>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type='text/javascript'>
var code ; //Define verification code function globally
createCode() {
code = "";
var codeLength = 4;//Length of verification code
var checkCode = document.getElementById("code");
var random = new Array(0,1,2,3,4,5,6,7 ,8,9,'A','B','C','D','E','F','G','H','I','J','K',' L','M','N','O','P','Q','R','S','T','U','V','W','X' ,'Y','Z'); //random number
for(var i = 0; i < codeLength; i++) {//loop operation
var index = Math.floor(Math.random()*36);//Get the index of the random number (0~35)
code += random[index];//According to the index to get the random number and add it to the code
}
checkCode.value = code;//Assign the code value to the verification code
}
//Verify the verification code
function validate(){
var inputCode = document.getElementById("input").value.toUpperCase(); //Get the input The verification code is converted to uppercase
if(inputCode.length <= 0) { //If the length of the entered verification code is 0
alert("Please enter the verification code!"); //Then please enter the verification code
}else if( inputCode != code ) { //If the input verification code is inconsistent with the generated verification code
alert("Verification code input error!@_@"); //The verification code input error pops up
createCode();//Refresh verification code
document.getElementById("input").value = ""; //Clear the text box
}else { //When the input is correct
alert("Qualified!^-^");
}
}
</script>
<style type='text/css'>
#code{
font-family:Arial,宋体;
font-style:italic;
color:green;
border:0;
padding:2px 3px;
letter-spacing:3px;
font-weight:bolder;
}
</style>
</head>
<body onload='createCode()'>
<div>验证码:
<input type = "text" id = "input"/>
<input type="button" id="code"onclick="createCode()" style="width:60px" title='Click to change the verification code' />
<input type = "button" value = "验证" onclick = "validate()"/>
</div>
</body>
</html>