// 随机验证码4个
// 0~9
// a~z
// A~Z
// random(0,9); 随机数字
// String.fromCharCode(random(97,122)); 随机小写
// String.fromCharCode(random(65,90)); 随机大写
// 1. 产生一个随机字符库,至少是12个,最好是3和4的公倍数个
<script>
var str ="";
for(var i=1;i<4;i++){
str +=random(0,9);
str += String.fromCharCode(random(97,122))
str += String.fromCharCode(random(65,90))
}
console.log(str);
var randomStr="";
for(var i=0;i<4;i++){
randomStr += str[random(0,str.length-1)];
}
console.log(randomStr);
function random(max,min){
return Math.round(Math.random()*(max-min)+min);
}
</script>