[JavaScript] fnRandomCode(codeLenth) - 获取验证码.js →→→→→进入此内容的聊天室

来自 , 2020-10-13, 写在 JavaScript, 查看 156 次.
URL http://www.code666.cn/view/cd3bbc2d
  1. //n位随机码
  2. var $codeChars = ['3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
  3. function fnRandomCode(codeLength) {
  4.     // 保存验证码的对象
  5.     var res = "",
  6.         index = -1;
  7.     for (var i = 0; i < codeLength; i++) {
  8.         index = Math.ceil(Math.random() * ($codeChars.length - 1));
  9.         if (index>-1) {
  10.             res += $codeChars[index];
  11.         } else {
  12.             res += '6';
  13.         }
  14.     }
  15.     return res;
  16. }

回复 "fnRandomCode(codeLenth) - 获取验证码.js"

这儿你可以回复上面这条便签

captcha