-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
31 lines (30 loc) · 1.27 KB
/
main.js
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
document.getElementById("len").defaultValue = 24;
document.getElementById("generate").addEventListener("click", getpass);
/*
var password= '';
var num = document.getElementById("len").value;
var alphabet = "`1234567890-=~!@#$%^&*()_+qwertyuiop[]\\QWERTYUIOP{}|asdfgjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?";
for ( i = 0; i < num ; i++)
{
password += alphabet[Math.floor((Math.random() * alphabet.length)* 1)];
}
document.getElementById('pass').textContent = password;
*/
function getpass() {
var num = document.getElementById("len").value;
if (num >= 8 && num <= 100){
var password= '';
var num = document.getElementById("len").value;
var alphabet = "`1234567890-=~!@#$%^&*()_+qwertyuiop[]\\QWERTYUIOP{}|asdfgjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?";
for ( i = 0; i < num ; i++)
{
password += alphabet[Math.floor(Math.random() * alphabet.length)];
}
document.getElementById('pass').textContent = password;
navigator.clipboard.writeText(password)
} else if (num < 8){
document.getElementById('pass').textContent = 'Minimum acceptable value is 8';
} else if (num > 100){
document.getElementById('pass').textContent = 'Maximum acceptable value is 100';
}
};