All,
I'm a noob, and have had a Java programming class a while back, but just can't get this, even though it should be an easy fix. I'm trying to set up a password generator that will spit out a list of passwords for me. The only choice I want is whether or not it will be 8 or 15 characters, and the passwords have to have certain characteristics (ex: 2 each of upper case, lower case, number and special characters). I wanted to run it in a simple html page, I am just having a problem with getting the "generate password" button to create multiple passwords to populate a list, and with getting a random password while specifying the minimum characteristics of 2 of each type.....
I've played with numerous different snippets, but this one seems to have the most potential if I could figure out where to go next. I think having several different keylists for the types would work, but how do I make that random (not a capital letter in the 1st position every time...)?
CODE
<html>
<head>
<script>
var keylist="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789!@#$%^&*()"
var temp=''
function generatepass(plength)
{
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}
function populateform(enterlength)
{
document.pgenerate.output.value=generatepass(enterlength)
}
</script>
</head>
<body>
<form name="pgenerate">
<b>Password Length:</b>
<input type="text" name="thelength" size=3 value="7"><br/>
<input type="text" size=25 name="output">
<input type="button" value="Generate Password"
onClick="populateform(this.form.thelength.value)">
</form>
</body>
</html>