-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_user.js
More file actions
44 lines (31 loc) · 1.11 KB
/
add_user.js
File metadata and controls
44 lines (31 loc) · 1.11 KB
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
const nextButton = document.querySelector('.next-button');
const userNameElement = document.getElementById('username');
const contactNoElement = document.getElementById('contact_no');
const emailElement = document.getElementById('email');
const passwordElement = document.getElementById('password');
const confirmPasswordElement = document.getElementById('confirm_password');
nextButton.addEventListener('click', () => {
if (confirmPasswordElement.value != passwordElement.value) {
alert("Password did not matched")
}
else {
const data = {
username: userNameElement.value,
phone: contactNoElement.value,
email: emailElement.value,
password: passwordElement.value
}
console.log(data)
fetch('http://127.0.0.1:8080/createUser', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data)
}).then(response => {
if (!response.ok) {
alert("invalid information");
}
})
}
})