-
Notifications
You must be signed in to change notification settings - Fork 1
/
otp.js
44 lines (37 loc) · 1.17 KB
/
otp.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
41
42
43
44
function OTPagain() {
setTimeout(() => {
let num = "1234567890";
let OTP = "";
for (let i = 0; i < 4; i++) {
OTP += num[Math.floor(Math.random() * 10)];
}
alert("Your OTP is " + OTP);
console.log(OTP);
localStorage.setItem("OTP", JSON.stringify(OTP));
}, 2000);
}
document
.getElementById("ButtonOTPvarification")
.addEventListener("click", function () {
let GetOTP = JSON.parse(localStorage.getItem("OTP"));
console.log(GetOTP);
let GetInput = document.getElementById("inputOTP").value;
console.log(GetInput);
if (GetOTP == GetInput) {
alert("Login Successfully");
location.href = "index.html";
document.getElementById("invalidOTP").style.display = "none";
} else {
let invalidOTP = document.getElementById("invalidOTP");
const displayData = (parentNode) => {
let div = document.createElement("div");
invalidOTP.innerText = "";
let invalid = document.createElement("p");
invalid.textContent = "Invalid OTP!";
invalid.style.color = "red";
div.append(invalid);
parentNode.append(div);
};
displayData(invalidOTP);
}
});