-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.html
137 lines (124 loc) · 5.17 KB
/
signup.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SignUp</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
<link rel="stylesheet" href="signup.css">
</head>
<body>
<div id="signUpForm" class="form Signup">
<div class="form-content">
<p style="color: green; text-align: center;" id="message"></p>
<header>Create Account</header>
<form id="signUp" action="#">
<div class="field input-field">
<input id="name" type="text" placeholder="Name" class="name">
<!-- <div class="message" id="nameMessage">name should be atleast of four characters</div> -->
</div>
<div class="field input-field">
<input id="mail" type="email" placeholder="Email" class="mail">
<div class="message" id="mailMessage"></div>
</div>
<div class="field input-field">
<input id="phone" type="number" placeholder="Phone" class="phone">
<div class="message" id="phoneMessage"></div>
</div>
<div class="field input-field">
<input id="passIn" type="password" placeholder="Password" class="password">
<i id="eyeOpen" class="fa-sharp fa-solid fa-eye "></i>
<i id='eyeClosed'class="fa-solid fa-eye-slash"></i>
<div id="passMessage"></div>
</div>
<div class="login-link">
<!-- <button>Signup</button> -->
<input type="submit" value="Signup" />
</div>
<div class="form-link">
<span> Already have an Account? <a href="login.html" class="signup-link">Login</a></span>
</div>
</form>
</div>
</div>
</body>
<script>
let customers=JSON.parse(localStorage.getItem("customers"));
if(customers==null){
customers=[];
}
let formData=document.querySelector("form");
formData.addEventListener("submit",(e)=>{
e.preventDefault();
let name=formData.name.value;
let email=formData.mail.value;
let phone=formData.phone.value;
let pass=formData.passIn.value;
let flag=false;
if(!name || !phone || !email || !pass){
alert("please enter the required fields!");
return;
}
if(name.length<4){
alert("name should be atleast of four characters");
// document.querySelector("#nameMessage").style.display="block";
return
}
for(let customer of customers){
if(customer.email==email){
flag=true;
break;
}
}
if(flag){
alert(`${email} has already been used`);
// swal({
// // // title:`${email} has already been used` ,
// // // text: "Sign in Unsuccessfull!",
// // // icon: "error",
// // // button: "try again",
// // // }).then(()=>{
// // // // event.preventDefault();
// // // // window.location = "menu.html";
// // // });
return
}
if(phone.length<10 || phone.length>10 ){
alert("phone number must be of 10 digits");
return;
}
swal({
title:`Congratulations dear ${name}, welcome! ` ,
text: "Sigup Successfull!",
icon: `U are registered here with ${email}`,
button: "now you can login",
}).then(()=>{
// event.preventDefault();
// window.location = "menu.html";
});
let obj={name,email,phone,pass};
customers.push(obj);
// console.log(obj)
localStorage.setItem("customers",JSON.stringify(customers));
console.log(customers)
});
let eyeClosed=document.getElementById("eyeClosed");
let eyeOpen=document.getElementById("eyeOpen");
eyeClosed.addEventListener("click",()=>{
let passText=document.querySelector("#passIn");
eyeOpen.style.display = "block";
eyeClosed.style.display = "none";
// eyeOpen.classList.add('show');
passText.type='text';
})
eyeOpen.addEventListener("click",()=>{
let passText=document.querySelector("#passIn");
eyeOpen.style.display = "none";
eyeClosed.style.display = "block";
passText.type='password';
})
</script>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js" integrity="sha512-AA1Bzp5Q0K1KanKKmvN/4d3IRKVlv9PYgwFPvm32nPO6QS8yH1HO7LbgB1pgiOxPtfeg5zEn2ba64MUcqJx6CA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- localStorage.setItem("formData", JSON.stringify(userData)); -->