아래 : 아래 :
다음과 같이 코드 코드를 복사하십시오.
<!
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = gb2312" /> />
<title> JS Verification Code </title>
<스타일 유형 = "텍스트/CSS">
.암호
{{
배경 이미지 : URL (code.jpg);
글꼴 패밀리 : arial;
글꼴 스타일 : 이탈리아;
색상 : 빨간색;
국경 : 0;
패딩 : 2px 3px;
문자 스페이스 : 3px;
글꼴 체중 : 대담한;
}
.Inchangeded
{{
국경 : 0;
}
</스타일>
<script language = "javaScript"type = "text/javaScript">
var 코드; // 전역 정의에서 검증 코드를 정의합니다
함수 createCode ()
{{
코드 = "";
var codength = 4; // 확인 코드의 길이
var checkCode = document.getElementById ( "CheckCode");
var selectchar = 새로운 배열 (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 , 's't ','u ','v ','ww ','x ','y ','z '); 중국어로 중국어를 사용할 수도 있습니다
for (var i = 0; i <codength; i ++)
{{
var charindex = math.floor (math.random ()*36);
코드 += selectchar [charindex];
}
// 경고 (코드);
if (checkcode)
{{
CheckCode.className = "Code";
CheckCode.Value = 코드;
}
}
함수 값 ()
{{
var inputCode = document.getElementById ( "input1");
if (inputCode.Length <= 0)
{{
Alert ( "확인 코드를 입력하십시오!");
}
else if (inputCode! = 코드)
{{
ALERT ( "검증 코드 입력 오류!");
createCode (); // 확인 코드를 새로 고침합니다
}
또 다른
{{
경고 ( "OK");
}
}
</스크립트>
</head>
<body only = "createCode ()">>
<form action = "#">
<입력 유형 = "text"id = "input1" />
<입력 유형 = "text"onclick = "createCode ()"readOnly = "readOnly"id = "checkcode" /> <br />
<input id = "button1"onclick = "validate ();"value = "ok" /> />
</form>
</body>
</html>