function testCode(n){
var arr= [];
for(var i = 1 ; i <= n ; i++){
var num = parseInt(Math.random() * 123);
if(num <= 9){
arr.push(num);
}else if((num >= 65 && num <= 90) || (num >= 97 && num <= 122)){
arr.push(String.fromCharCode(num));
}else{
i--
}
}
return arr.join("");
}
alert(test(6));
//纯数字验证码
function test(n){
var arr = [];
for(var i = 1 ; i <= n ; i++){
var num = parseInt(Math.random() * 10);
arr.push(num);
}
return arr.join('');
}
alert(test(4));