-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
108 lines (88 loc) · 2.93 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>PayApp - Signup</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary static-top">
<div class="container">
<a class="navbar-brand" href="/groups.html">PayApp</a>
</div>
</nav>
<!-- Page Content# -->
<div class="container" style="max-width: 400px;">
<br>
<br>
<br>
<h3>Sign Up</h3>
<br>
<form>
<div class="form-group">
<label for="inputemail">Email</label>
<input type="email" class="form-control" id="inputemail" placeholder="Enter email" required>
</div>
<div class="form-group">
<label for="inputpmount">Password</label>
<input type="password" class="form-control" id="inputpassword" placeholder="Enter password" required>
</div>
<br>
<button type="submit" id="submitchange" class="btn btn-primary">Sign Up</button>
</form>
<br>
<p>Already have an account? <a href="login.html">Log in</a></p>
<br>
<div class="alert alert-success" role="alert" id="successalert" style="display:none">
Successfully created new user! You can now <a href="login.html">login</a>.
</div>
<div class="alert alert-danger" role="alert" id="erroralert" style="display:none">
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Utility functions -->
<script src="connection.js"></script>
<script>
var host = getHost();
$("form").on("submit", function (e) {
e.preventDefault();
});
$("#submitchange").on("click", function (e) {
if ($(this).parent()[0].checkValidity()){
var email = $("#inputemail").val();
localStorage.setItem("email", email);
var password = $("#inputpassword").val();
$.ajax({
url : host + "signup",
type : "POST",
data : JSON.stringify({
"email": email,
"password": password
}),
dataType: "json",
success : function(data) {
$("#erroralert").hide();
$("#successalert").show();
},
error : function(response, error) {
if (response["status"]==400){
console.log(response)
$("#erroralert").text(response["responseJSON"]["message"]);
$("#erroralert").show();
} else {
alert("Something went wrong. Try again now or at a later time.");
}
}
});
}
});
</script>
</body>
</html>