<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>随机验证码</title>
</head>
<body>
<span id="msg"></span>
<input type="button" value="刷新" onclick="show()">
<script>
function validateCode(n){
var s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
var ret="";
for(var i=0;i<n;i++){
var index=Math.floor(Math.random()*62);
ret+= s.charAt(index);
// alert(Math.floor(Math.random()*62));
}
return ret;
}
function show(){
document.getElementById("msg").innerHTML=validateCode(5);
}
function renovates(){
document.location.reload();
}
window.onload=show;
</script>
</body>
</html>
时间: 2024-11-03 01:16:16