jQuery随机密码生成的方法_jquery
程序员文章站
2022-04-20 12:24:44
...
本文实例讲述了jQuery随机密码生成的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
$.extend({
password: function (length, special) {
var iteration = 0;
var password = "";
var randomNumber;
if(special == undefined){
var special = false;
}
while(iteration randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
if(!special){
if ((randomNumber >=33) && (randomNumber if ((randomNumber >=58) && (randomNumber if ((randomNumber >=91) && (randomNumber if ((randomNumber >=123) && (randomNumber }
iteration++;
password += String.fromCharCode(randomNumber);
}
return password;
}
});
// How to use
$.password(8);
$.password(12, true);
password: function (length, special) {
var iteration = 0;
var password = "";
var randomNumber;
if(special == undefined){
var special = false;
}
while(iteration randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
if(!special){
if ((randomNumber >=33) && (randomNumber if ((randomNumber >=58) && (randomNumber if ((randomNumber >=91) && (randomNumber if ((randomNumber >=123) && (randomNumber }
iteration++;
password += String.fromCharCode(randomNumber);
}
return password;
}
});
// How to use
$.password(8);
$.password(12, true);
希望本文所述对大家的jQuery程序设计有所帮助。
上一篇: php—Smarty-5 (22),phpsmarty-522
下一篇: 值得玩味儿的生活小笑段