This repository has been archived by the owner on Dec 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registration.html
91 lines (83 loc) · 2.97 KB
/
registration.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
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Chart generator</title>
<link rel="stylesheet" href="css/styles.css">
<script src="javascript/menu.js"></script>
<script src="javascript/submit.js"></script>
<script src="javascript/utils.js"></script>
<script src="javascript/registration.js"></script>
</head>
<body>
<div class="header">
<h1>Chart generator</h1>
</div>
<div id="navbar">
<a href="login.html">Login</a>
<a href="registration.html">Registration</a>
<ul>
<li id="user"><a href="login.html"><img src="image/user_icon.png" alt="user" height="26" width="26"></a></li>
</ul>
</div>
<div id="container">
<div style="float: left; width: 25%; height: 80%;"><span style="color: white">.</span></div>
<div class="block" style="overflow: hidden">
<div class="header">
<span>REGISTRATION</span>
</div>
<div class="center" style="border: none;">
<input type="text" placeholder="username" id="username"/><br>
<input type="password" placeholder="password" id="password"/><br>
<input type="password" placeholder="ConfirmPassword" id="confirm_password"/><br>
<input type="submit" value="REGISTRATION" onclick="register()"/>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
</body>
<div class="footer">
2018, FMI, Web Technologies 10th edition, Denis Duev, Mihaela Chakova
</div>
<script>
function register() {
var user = document.getElementById("username").value;
var pass = document.getElementById("password").value;
if (!isPasswordValid(pass)) {
return;
}
var data = JSON.stringify({
"username": user,
"password": pass
});
$.ajax({
url: '/javascript/registration',
type: 'POST',
data: data,
contentType: "application/json; charset=utf-8",
success: function (data) {
var res = JSON.parse(data);
if (res.status === true) {
var location = window.location.href;
window.location.href = location.replace("/registration", "/login");
alert("registration successful");
} else {
alert("registration failed");
}
}
});
}
function isPasswordValid(pass) {
var confirmPass = document.getElementById("confirm_password").value;
if (pass == "" || confirmPass == "") {
alert("All fields are required");
return false;
}
if (pass != confirmPass) {
alert("The passwords don't match");
return false;
}
return true;
}
</script>
</html>