JQuery random password Generation Method
This article mainly introduces the method for generating jQuery random passwords. The example analyzes jQuery's random number operation skills and has some reference value. For more information, see
This document describes how to generate a jQuery random password. Share it with you for your reference. The specific implementation method is as follows:
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 help you with jQuery programming.