-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
64 lines (58 loc) · 2.41 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<title>Password Generator</title>
</head>
<body>
<h1>Password Generator</h1>
<p>Enter your desired password length and select any optional settings:</p>
<form>
<label for="length">Password Length:</label><br>
<input type="number" id="length" name="length" min="8" max="128" value="8"><br>
<input type="checkbox" id="uppercase" name="uppercase" value="uppercase">
<label for="uppercase">Include uppercase letters</label><br>
<input type="checkbox" id="lowercase" name="lowercase" value="lowercase">
<label for="lowercase">Include lowercase letters</label><br>
<input type="checkbox" id="numbers" name="numbers" value="numbers">
<label for="numbers">Include numbers</label><br>
<input type="checkbox" id="symbols" name="symbols" value="symbols">
<label for="symbols">Include symbols</label><br><br>
<button type="button" onclick="generatePassword()">Generate Password</button>
</form>
<br>
<p>Generated Password:</p>
<p id="password"></p>
<script>
function generatePassword() {
// get the length of the password from the form
var length = document.getElementById("length").value;
// possible characters to include in the password
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lowercase = "abcdefghijklmnopqrstuvwxyz";
var numbers = "0123456789";
var symbols = "!@#$%^&*()_+-=[]{}|;':\",.<>?";
// variables to store the password character sets
var passwordChars = "";
var password = "";
// check which character sets the user wants to include
if (document.getElementById("uppercase").checked) {
passwordChars += uppercase;
}
if (document.getElementById("lowercase").checked) {
passwordChars += lowercase;
}
if (document.getElementById("numbers").checked) {
passwordChars += numbers;
}
if (document.getElementById("symbols").checked) {
passwordChars += symbols;
}
// generate the password
for (var i = 0; i < length; i++) {
password += passwordChars.charAt(Math.floor(Math.random() * passwordChars.length));
}
// display the password on the webpage
document.getElementById("password").innerHTML = password;
}
</script>
</body>
</html>