-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
40 lines (39 loc) · 1.3 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
32
33
34
35
36
37
38
39
40
let firstInput = document.querySelector(".first");
let button = document.querySelector("button");
let secondInput = document.querySelector(".second");
let CheckBtn = document.querySelector(".secondBtn");
let endText = document.querySelector(".endText");
CheckBtn.addEventListener("click", e => {
e.preventDefault();
let inputVal = secondInput.value.split("").join("");
if (inputVal == firstInput.innerText) {
endText.innerText = " nice Captcha matched";
endText.style.display = "block";
endText.style.color = "#fff";
setTimeout(() => {
endText.innerText = "";
endText.style.display = "";
endText.style.color = "";
getCaptcha();
}, 4000);
} else {
endText.innerText = "Captcha not matched. Please Try Again Later";
endText.style.display = "block";
endText.style.color = "#000";
}
});
function getCaptcha() {
var chars =
"0123456789qwertyuiopasdfghjklzxcvbnm!@#$%^&*()QWERTYUIOPASDFGHJKLZXCVBNM";
var passwordLength = 12;
var password = "";
for (let i = 0; i <= passwordLength; i++) {
var RandomPassword = Math.floor(Math.random() * chars.length);
password += chars.substring(RandomPassword, RandomPassword + 1);
}
firstInput.innerText = password;
}
button.addEventListener("click", e => {
firstInput.innerText = "";
getCaptcha();
});