function getCode(length){
if(length=="undefined"){
length=4;
}
var rand,
current=0,
code="";
while(current<length){
rand=Math.floor(Math.random()*(122-48+1)+48);
if(rand<65&&rand>57||rand<97&&rand>90){
continue;
}
code+=String.fromCharCode(rand);
current++;
}
return code
}
document.write(getCode(6))
生成含有字母数字任意位数的验证码
最新推荐文章于 2024-07-26 20:46:33 发布