-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
23 lines (21 loc) · 808 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const password_ele = document.getElementById("pwd_txt");
var string = "ABCDEFGHIJKLMNOPQRSTUVWXYZacdefghijklnopqrstuvwxyz0123456789";
const special_chars = "@#$%^&*";
const generate = document.getElementById("generate");
const clipboard = document.getElementById("clipboard");
var pwd_length = document.getElementById("slider");
generate.addEventListener('click', () => {
let password = "";
var checked = document.getElementById("checkbox").checked;
var final_string = string;
console.log(checked);
if (checked) {
final_string += "@#$%^&*";
}
for (var i = 0; i < pwd_length.value; i++) {
let pwd = final_string[Math.floor(Math.random() * final_string.length)];
password += pwd;
}
password_ele.innerText = password;
final_string = string;
});