forked from nikhildeora/cool-monk-ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.html
192 lines (175 loc) · 6.6 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!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 Page</title>
<link rel="stylesheet" href="styles/nav_fot.css">
<script src="https://kit.fontawesome.com/1fedb2eabf.js" crossorigin="anonymous"></script>
<style>
*{
/* width: 70%;
height: auto;
margin: auto; */
padding: 0px;
margin: 0px;
/* text-align: center; */
}
#signup_form{
width: 100%;
display: grid;
margin: auto;
margin-top: 50px;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
border-radius: 15px;
border: 2px solid rgb(215, 215, 233);
background-color: #545871;
color: white;
font-size: 25px;
}
#signup_div{
width: 30%;
margin: auto;
padding: 10px;
margin-top: 42px;
margin-bottom: 35px;
/* border: 1px solid black; */
/* margin: 0px; */
/* text-align: center; */
}
#signup_form input, #signup_form label,#eye{
padding: 12px;
margin: 0px 23px 0px 23px;
/* margin: auto; */
}
#signup_button{
background-color: white;
color: #545871;
padding: 10px;
font-size: 22px;
border: 1px solid black;
margin: 0px 23px 10px 23px;
}
#signup_button:hover{
background-color: #545871;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<div id="navbar"></div>
<div id="signup_div">
<form action="" id="signup_form">
<div style="text-align: center">Sign Up</div>
<label for="">Full Name</label>
<input id="name" type="text" placeholder="Ente your full name" required>
<label for="">Email</label>
<input id="email" type="email" placeholder="Email" required>
<label for="">Password</label>
<input id="pwd" type="password" placeholder="Password"><span><i class="fa-solid fa-eye" id="eye" ></i></span>
<button id="signup_button">SIGN UP</button>
</form>
<p>Already have an account? <a href="login.html"> Sign In<span style="color: blue"></span> </a> </p>
</div>
<div id="footer"></div>
</body>
</html>
<script type="module">
import navbar from "./cmmponents/navbar.js"
let navbar_div = document.getElementById("navbar")
navbar_div.innerHTML = navbar()
import footer from "./cmmponents/footer.js"
let footer_div = document.getElementById("footer")
footer_div.innerHTML = footer()
let form= document.querySelector("form")
form.addEventListener("submit", store);
let signupArr= JSON.parse(localStorage.getItem("signup")) ||[]
function store(event){
event.preventDefault()
let obj={
username :document.querySelector("#name").value,
email: document.querySelector("#email").value,
password: document.querySelector("#pwd").value,
}
// storeData(obj)
check_api(obj)
}
async function check_api(obj){
try{
// let res = await fetch(`https://powerful-savannah-17761.herokuapp.com/details`)
let res = await fetch(`https://render-deployed-fitnexy.onrender.com/userprofile`)
let data = res.json()
data.then((jhs)=>{
let check = 0;
jhs.forEach(el => {
// console.log(el);
if(obj.email==el.email){
check++
}
});
if(check>0){
alert("We Already have an Account with this Email Id")
}
else{
check_strength(obj)
}
})
}
catch(er){
console.log(er);
}
}
// password should carry Capital letters, small letters, symbols & numbers & length should not be less than 12
function check_strength(obj) {
var strongRegex = new RegExp("^(?=.{12,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{8,}).*", "g");
if (obj.password.length == 0) {
alert("Type password, password should carry Capital letters, small letters, symbols & numbers & length should not be less than 12 ")
} else if (false == enoughRegex.test(obj.password)) {
alert("Please type some More Characters, password should carry Capital letters, small letters, symbols & numbers & length should not be less than 12 ")
} else if (strongRegex.test(obj.password)) {
alert("Your password is strong!")
storeData(obj)
} else if (mediumRegex.test(obj.password)) {
alert("Your password strength is Medium! , password should carry Capital letters, small letters, symbols & numbers & length should not be less than 12 ")
} else {
alert("Your password strength is Weak! , password should carry Capital letters, small letters, symbols & numbers & length should not be less than 12 ")
}
}
async function storeData(details){
try{
// let res= await fetch (`https://powerful-savannah-17761.herokuapp.com/details`,{
let res= await fetch (`https://render-deployed-fitnexy.onrender.com/userprofile`,{
method: 'POST',
body: JSON.stringify(details),
headers: {
'Content-Type': 'application/json'
}
})
let data= await res.json()
console.log(data)
window.location.href="./login.html"
}catch(err){
console.log(err)
}
}
let state=false;
// onclick="toggle()"
let eye = document.getElementById("eye")
eye.addEventListener("click",toggle)
function toggle(){
if(state){
document.getElementById("pwd").setAttribute("type", "password")
document.getElementById("eye").style.color="#7a797e"
state=false;
}
else{
document.getElementById("pwd").setAttribute("type", "text")
document.getElementById("eye").style.color="#5887ef"
state=true;
}
}
</script>