& lthead & gt
& lt腳本語言= " JavaScript " type = " text/JavaScript " & gt;
var代碼;
函數createCode(){
code = new Array();
var碼長= 4;
var check code = document . getelementbyid(" check code ");
checkCode.value =
var selectChar = new Array(2,3,4,5,6,7,8,9,' A ',' B ',' C ',' D ',' E ',' F ',' G ',' H ',' J ',' K ',' L ',' M ',' N ',' P ',' Q ',' R ',' S ',' T ',' U ',' V ',' W ',' X ',' Y ',' Z ');
for(var I = 0;我& lt碼長;i++) {
var char index = math . floor(math . random()* 32);
code+= select char[char index];
}
checkCode.value = code
}
函數驗證(){
var input code = document . getelementbyid(" yzm ")value . toupper case();
if(inputCode!= code ){ alert("驗證碼不正確!");返回false}
Else {alert("驗證碼正確!");返回true}
}
& lt/script & gt;
& ltmeta http-equiv = " Content-Type " Content = " text/html;charset=gb2312 " >
& lt/head & gt;
& ltbody onLoad = " create code();"& gt
驗證碼:
& ltinput type = " button " ID = " check code " onclick = " create code()" title = "刷新驗證碼" style = " width:50px;顏色:# F00邊框:0;字母間距:1px;字體系列:Arial”/& gt;
& ltinput type = " button " id = " button 1 " onClick = " validate();"value = " OK "/& gt;
& lt/body & gt;
& lt/html & gt;