-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
61 lines (53 loc) · 1.82 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up - TalkCrate</title>
<style>
</style>
</head>
<body>
<div class="container">
<header>
TalkCrate Sign Up
</header>
<form onsubmit="return validateForm()">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="newpassword">Password:</label>
<input type="password" id="newpassword" name="newpassword" required>
<button type="submit">Sign Up</button>
</form>
<p>Already have an account? <a href="index.html">Log in here</a>.</p>
</div>
<script>
function validateForm() {
var username = document.getElementById("username").value;
var password = document.getElementById("newpassword").value;
fetch('https://https://talk-crate-d9uc.vercel.app//api/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
// Handle successful response from the server
console.log('Success:', data);
})
.catch((error) => {
// Handle error
console.error('Error:', error);
});
return false; // Prevent the form from actually submitting
}
</script>
</body>
</html>