forked from osPrims/chatApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
180 lines (162 loc) · 4.96 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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap CSS -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<title>Signup</title>
<style>
.form {
width: 400px;
height:500px;
border:1.5px solid rgb(206, 212, 218);
padding:20px;
}
.cover {
align-items: center;
display: flex;
justify-content: center;
height:100vh;
}
.fontsize{
font-size: 14px;
}
.account{
font-size: 14px;
}
.login{
color:rgb(220, 53, 69);
text-decoration: none;
}
.heading{
text-align:center;
font-size: 20px;
}
#email-error,#password-error{
color:rgb(220, 53, 69);
font-size: 14px;
}
</style>
</head>
<body>
<div class="cover">
<div class="form">
<h3 class="heading">SIGN UP</h3>
<form>
<div class="mb-3">
<label for="exampleInputname" class="form-label fontsize"
>Enter Your Name:*</label
>
<input
type="text"
class="form-control fontsize"
id="exampleInputname"
aria-describedby="emailHelp"
required
placeholder="Enter Name"
name="username"
/>
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label fontsize"
>Email Address:*</label
>
<input
type="email"
class="form-control fontsize"
id="exampleInputEmail1"
aria-describedby="emailHelp"
required
placeholder="Enter Email-id"
name="email"
/>
</div>
<div id="email-error"></div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label fontsize"
>Password:*</label
>
<input
type="password"
class="form-control fontsize"
id="exampleInputPassword1"
required
placeholder="Create Password"
name="password"
/>
</div>
<div id="password-error"></div>
<div class="mb-3">
<label for="exampleInputPassword2" class="form-label fontsize"
>Confirm Password:*</label
>
<input
type="password"
class="form-control fontsize"
id="exampleInputPassword2"
required
placeholder="Confirm Password"
name="conpassword";
/>
</div>
<button type="submit" class="btn btn-danger">SIGN UP</button>
<br>
<span class="account"> Have a account?</span>
<a class="login" href="/login">Login</a>
</form>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"
></script>
<script>
const emailerror=document.getElementById("email-error");
const passworderror=document.getElementById("password-error");
const form=document.querySelector("form");
form.addEventListener("submit", async(e)=>{
e.preventDefault();
emailerror.innerHTML="";
passworderror.innerHTML="";
const username=form.username.value;
const email=form.email.value;
const password=form.password.value;
const conpassword=form.conpassword.value;
console.log(form.password.value);
console.log(form.conpassword.value);
try{
const res=await fetch("/signup",{
method:"POST",
body:JSON.stringify({username:username,
email:email,
password:password,
conpassword:conpassword
}),
headers:{"Content-Type":"application/json"}
});
const data=await res.json();
if(data.error)
{
emailerror.innerHTML=data.error.email;
passworderror.innerHTML=data.error.password;
};
if(data.user)
{
location.assign("/login")
}
}
catch (err){
console.log(err);
}
})
</script>
</body>
</html>