Home > Web Front-end > JS Tutorial > jQuery random password generation method_jquery

jQuery random password generation method_jquery

WBOY
Release: 2016-05-16 16:10:45
Original
1357 people have browsed it

The example in this article describes the jQuery random password generation method. Share it with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:
$.extend({
Password: function (length, special) {
var iteration = 0;
var password = "";
var randomNumber;
If(special == undefined){
         var special = false;
}
While(iteration < length){
         randomNumber = (Math.floor((Math.random() * 100)) % 94) 33;
         if(!special){
If ((randomNumber >=33) && (randomNumber <=47)) { continue; }
If ((randomNumber >=58) && (randomNumber <=64)) { continue; }
If ((randomNumber >=91) && (randomNumber <=96)) { continue; }
If ((randomNumber >=123) && (randomNumber <=126)) { continue; }
}
iteration ;
Password = String.fromCharCode(randomNumber);
}
Return password;
}
});
// How to use
$.password(8);
$.password(12, true);

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template