js生成随机字母加数字码

function randomRange(min, max){
                var returnStr = "",
                    range = (max ? Math.round(Math.random() * (max-min)) + min : min), //随机整数,内层:x(范围在【min~max-min),min。外层:【x到min]
                    charStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

                for(var i=0; i
结果KBBHNW8V4Y

如果想要包含小写,只需要把charStr改一下

charStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

 

你可能感兴趣的:(js)