-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignUp.js
61 lines (45 loc) · 1.59 KB
/
SignUp.js
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
const LOGIN_DATABASE_URI = "http://localhost:4000/Users";
$(document).ready(function (){
var $email = $('#email');
var $username = $('#username');
var $password = $('#password');
$('#signUp').on('click', function (e) {
e.preventDefault();
// A function to check if the fields are empty
function checkData(caller){
if (caller.val() == ""){
// console.log(caller.parent().closest('small'));
return false;
} else {
return true;
}
}
if(checkData($email) && checkData($username) && checkData($password)){
var details = {
email: $email.val(),
UserName: $username.val(),
PassWord: $password.val()
};
//console.log(details)
//$.post("http://localhost:4000/Users", details, alert('User has been created'));
$.ajax({
type: 'POST',
url: LOGIN_DATABASE_URI,
data: details,
success: function () {
//alert('saved Successfully, now you can log in!');
M.toast({
html: 'saved Successfully, now you can log in! ❗'
});
},
error: (error) => {
alert('error saving!');
}
});
} else {
M.toast({
html: 'Make sure you filled out all the required fields ❗'
});
}
});
});