-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_signup.js
36 lines (31 loc) · 1.2 KB
/
script_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
document.getElementById('signuppg').addEventListener('submit', async function(event) {
event.preventDefault();
const Name = document.getElementById('Name').value;
const Phone = document.getElementById('Phone').value;
const Email = document.getElementById('Email').value;
const Loginid = document.getElementById('Loginid').value;
const Password = document.getElementById('Password').value;
const ConfirmP = document.getElementById('ConfirmP').value;
if (Password !== ConfirmP) {
alert('Password and Confirm Password do not match.');
return;
}
try {
const response = await fetch('http://localhost:3000/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ Name,Phone,Email,Loginid,Password,ConfirmP }),
});
const data = await response.json();
if (data.success) {
alert('User registered successfully! Please click on the Main Page to Proceed');
} else {
alert('Login Id exists. Please try again.');
}
} catch (error) {
console.error('Error:', error);
alert('An error occurred. Please try again later.');
}
});