-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path27.html
More file actions
45 lines (41 loc) · 1.71 KB
/
Copy path27.html
File metadata and controls
45 lines (41 loc) · 1.71 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Password Generator</title>
</head>
<body>
<h1>Random Password Generator</h1>
<label for="length">Password Length:</label>
<input type="number" id="length" min="1" max="50" value="8">
<br><br>
<input type="checkbox" id="uppercase"> Uppercase
<input type="checkbox" id="lowercase"> Lowercase
<input type="checkbox" id="numbers"> Numbers
<input type="checkbox" id="special"> Special Characters
<br><br>
<button onclick="generatePassword()">Generate Password</button>
<p id="password"></p>
<script>
function generatePassword() {
const length = document.getElementById('length').value;
const uppercase = document.getElementById('uppercase').checked;
const lowercase = document.getElementById('lowercase').checked;
const numbers = document.getElementById('numbers').checked;
const special = document.getElementById('special').checked;
let characters = '';
if (uppercase) characters += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (lowercase) characters += 'abcdefghijklmnopqrstuvwxyz';
if (numbers) characters += '0123456789';
if (special) characters += '!@#$%^&*()_+~`|}{[]\:;?><,./-=';
let password = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
password += characters[randomIndex];
}
document.getElementById('password').textContent = password;
}
</script>
</body>
</html>