-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (89 loc) · 1.9 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html>
<head>
<title>Random password generator</title>
<style type="text/css">
.section {
background-color: #011526;
padding: 15px;
margin-bottom: 10px;
border-radius: 10px;
width: 70%;
}
p{
font-size: 30px;
color: white;
}
.submit {
background-color:green;
padding: 12px 45px;
border-radius: 5px;
cursor: pointer;
color: #ffffff;
border: none;
outline: none;
margin: 0;
font-weight: bold;
}
.submit:hover {
background-color:orange;
}
input
{
-moz-border-radius: 15px;
border-radius: 15px;
border:solid 1px black;
outline :none;
padding:5px;
}
</style>
</head>
<body bgcolor="#F0D000">
<center>
<h1>welcome to the Random password generator</h1>
</center>
<br><br>
<center>
<div class="section">
<p><b>Enter the Length of your password:</b></p>
<input type="number" name="" id="l1"><br>
<p><b>Enter the characters for your password:</b></p>
<input type="text" name="" id="l2"><br><br>
<center>
<input type="button" value="submit" class="submit" onclick="checker()">
</center>
</div>
</center>
<br><br><br>
<center>
<div class="section">
<p id="txt1"></p>
</div>
</center>
<script type="text/javascript">
var Length; //length of password
var characters; //characters for your password
function checker() {
Length=(+ document.getElementById("l1").value);
characters=document.getElementById("l2").value;
if (Length=="" || characters.length==0) {
alert("length of characters or length should not be zero")
}
else{
generatePassword(Length,characters);
}
}
function generatePassword(Length,characters) {
let password="";
for (let i=0;i<Length;++i) {
password +=characters[
Math.floor(
Math.random()*characters.length
)
];
}
document.getElementById("txt1").innerHTML=password;
}
</script>
</body>
</html>