-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgotpass.js
60 lines (53 loc) · 2.16 KB
/
forgotpass.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
document.getElementById("forotp").addEventListener("click",getotp);
var email;
var old_data;
var num;
function getotp(){
email=document.getElementById("email").value;
old_data = JSON.parse(localStorage.getItem("signupData"));
for (var i = 0; i < old_data.length; i++) {
if (email == old_data[i].email) {
num=i;
document.getElementById("enterotp").style.display="block";
return;
}
}
alert("Please Enter Registered Email");
document.getElementById("email").value="";
}
document.getElementById("submite").addEventListener("click",setpassword);
function setpassword(){
var otp=document.getElementById("otp1").value;
console.log(otp);
if (otp == "1234") {
document.getElementById("submite").style.display="none";
document.getElementById("updatePass").style.display="block";
document.getElementById("forotp").style.display="none";
document.getElementById("forgoth1").innerText="Update New Password";
document.getElementById("forgotp").innerText="You are just one step away for Sign-In";
document.getElementById("forgoth2").innerText="Step 2";
document.getElementById("forgotl1").innerText="Enter New Password";
document.getElementById("forgotl2").innerText="Confirm New Password";
document.getElementById("email").value="";
document.getElementById("otp1").value="";
}
else {
alert("Please Enter Valid Otp");
document.getElementById("otp1").value="";
}
}
document.getElementById("updatePass").addEventListener("click",changePassword);
function changePassword(){
var newPass=document.getElementById("email").value;
var confPass=document.getElementById("otp1").value;
if (newPass!=confPass){
alert("New Password and Confirm Password Should be the Same");
document.getElementById("email").value="";
document.getElementById("otp1").value="";
return;
}
old_data[num].password=newPass;
localStorage.setItem("signupData",JSON.stringify(old_data));
alert("new Password set Succesfully")
window.location.href="./signin.html";
}