var code;//in Global definition Authenticode//generate CAPTCHA window.onload = function Createcode () {code = "";
var codelength = 4;//The length of the authentication 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++) {//cyclic operation var index = Math.floor (Math.ran
Dom () *36); Index of random number (0~35) code + random[index];//add random number to code based on index checkcode.value = code;//Assign code value to verification code}//Checksum verification code function validate () {var inputcode = document.getElementById ("input"). Value.touppercase ();//Get the input verification code and convert it to uppercase if ( Inputcode.length <= 0) {//If the length of the authentication code entered is 0 alert ("Please enter the verification code!"). "); Then eject please enter the verification code} else if (Inputcode!= code) {//If the authentication code entered is inconsistent with the resulting Authenticode ("Authenticode input Error!"). @_@"); Then eject the authentication code input error Createcode ()//Refresh the Authentication code document.getElementById ("input"). Value = "";/Empty text box} else {//input correct alert ("^-^"); Popup ^}}