-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.html
103 lines (83 loc) · 3.09 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Sign-up | To-Do</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--Google Fonts-->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Staatliches&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Oswald&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap" rel="stylesheet">
<link rel="icon" href="css/images/icon.PNG">
</head>
<body>
<ul class="nav-bar" id="nav-bar">
<li><a href="/">Home</a></li>
<li id="right"><a href="/signUp">Sign Up</a></li>
<li id="right"><a href="/logIn">Log In</a></li>
</ul>
<div class="log-in-box">
<div class="form">
<h1 class="title">Sign-Up</h1>
<form class="sign-up-form signUp-form" autocomplete="off">
<label for="fname">First Name:</label><br>
<input name="fname" id="fname" type="text" required>
<br>
<br>
<label for="lname">Last Name: </label><br>
<input name="lname" id="lname" type="text" required>
<br>
<br>
<label for="email">Email: </label><br>
<input name="email" id="email" type="text" required>
<br>
<br>
<label for="username">UserName: </label><br>
<input name="username" id="username" type="text" required>
<br>
<br>
<label for="password">Password: </label><br>
<input name="password" id="password" type="text" style="-webkit-text-security: disc;" required>
<br>
<br>
<button name="submit" type="submit" class="submit">Submit</button>
<p id="message" style="margin-bottom: 0;"></p>
</form>
</div>
</div>
<br>
<script>
var form = document.querySelector(".signUp-form");
form.addEventListener("submit", async (e) => {
e.preventDefault();
try {
const req = await fetch("/signUp", {
method: "POST",
body: JSON.stringify({
fname: document.getElementById('fname').value,
lname: document.getElementById('lname').value,
email: document.getElementById('email').value,
username: document.getElementById('username').value,
password: document.getElementById('password').value,
}),
headers: {
"Content-Type": "application/json"
}
});
const res = await req.json();
if (res.error == false) {
window.location.replace("/logIn");
} else {
document.getElementById("message").innerHTML = res.message;
}
} catch (err) {
document.getElementById("message").innerHTML = err;
}
})
</script>
</body>
</html>