`
y_zjx
  • 浏览: 173616 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

js 生成验证码

    博客分类:
  • js
 
阅读更多
<!DOCTYPE html>[color=olive][/color]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>找回密码</title>
<link type="text/css" rel="stylesheet" href="style.css" />
<style type="text/css">
.code{
font-family: Arial;
font-style: italic;
color:Red;
border:0;
padding:2px 3px;
letter-spacing: 3px;
font-weight: bolder;
width: 50px;
line-height:30px;
}
.unchanged{
border:0;
}
</style>
<script type="text/javascript" charset="utf-8">

function createCode(){
var randomCode ="";
var codeLength = 4;
var selectRange = 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');
var random = document.getElementById("random");
for(var i=0;i<codeLength;i++){
var randomIndex = Math.floor(Math.random()*34);
randomCode += selectRange[randomIndex];
}
alert(randomCode);
if(random){
random.className="code";
random.value=randomCode;
}
}
</script>
<body onload="createCode();">
   <input id="random" type="text" class="unchanged" value="" readonly="readonly"/><a href="#"onclick="createCode();"看不清,换一张</a>
</body>
分享到:
评论
1 楼 combaxiao 2013-04-01  
有没有可以生成干扰条的

相关推荐

Global site tag (gtag.js) - Google Analytics