<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>Enter the title of your XHTML document here</title>
  <script type="text/javascript">
    function getCode()
                {
                 var code="";
  var codeLength = 4;//验证码的长度
  var checkCode = document.getElementById("code");
  checkCode.innerText = "";
  
  var selectChar = new Array(0,1,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;i<codeLength;i++) {
     var charIndex = Math.floor(Math.random()*32);
     code +=selectChar[charIndex];
               }     
             
  checkCode.innerText = code;
}
 
       

  </script>
 </head>
 <body onload="getCode()">
  <p>Enter the body text of your XHTML document here</p>
  
                验证码:<span id="code" style="color: red"></span>&nbsp;&nbsp;&nbsp;<span onclick="getCode()" style="cursor: hand">看不清点我</span>
 </body>
</html>

posted on 2010-10-19 16:23  新小白龙  阅读(460)  评论(0编辑  收藏  举报