Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I would like to create a password generator using javascript or something but how do I do this because I want to create a password that is 6 digits long, and it needs to be 3 letters followed by three number, i.e "abc123". Any help would be greatly appreciated!

Upper case letters only:
function generatePassword() {
a1 = Math.floor(Math.random()*26+65);
a2 = Math.floor(Math.random()*26+65);
a3 = Math.floor(Math.random()*26+65);
n1 = Math.floor(Math.random()*10+48);
n2 = Math.floor(Math.random()*10+48);
n3 = Math.floor(Math.random()*10+48);password = String.fromCharCode(a1,a2,a3,n1,n2,n3);
return password;
}
Lower case letters only:function generatePassword() {
a1 = Math.floor(Math.random()*26+97);
a2 = Math.floor(Math.random()*26+97);
a3 = Math.floor(Math.random()*26+97);
n1 = Math.floor(Math.random()*10+48);
n2 = Math.floor(Math.random()*10+48);
n3 = Math.floor(Math.random()*10+48);password = String.fromCharCode(a1,a2,a3,n1,n2,n3);
return password;
}
Upper and lower case letters:function generatePassword() {
a1 = Math.floor(Math.random()*52+65);
a1 = (a1 > 90) ? a1 + 6 : a1;
a2 = Math.floor(Math.random()*52+65);
a2 = (a2 > 90) ? a2 + 6 : a2;
a3 = Math.floor(Math.random()*52+65);
a3 = (a3 > 90) ? a3 + 6 : a3;
n1 = Math.floor(Math.random()*10+48);
n2 = Math.floor(Math.random()*10+48);
n3 = Math.floor(Math.random()*10+48);password = String.fromCharCode(a1,a2,a3,n1,n2,n3);
return password;
}Michael J

![]() |
setting up IIS
|
Javascript form
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |