-
Notifications
You must be signed in to change notification settings - Fork 2
/
signup.js
23 lines (19 loc) · 939 Bytes
/
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
document.getElementById('contactForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting immediately
let name = document.getElementById('name').value;
let surname = document.getElementById('surname').value;
let email = document.getElementById('email').value;
let formMessage = document.getElementById('formMessage');
if (name === '' || email === '' || surname === '') {
formMessage.textContent = "All fields are required!";
formMessage.style.color = 'red';
formMessage.classList.remove('hidden');
} else {
formMessage.textContent = "Signed Up successfully!";
formMessage.style.color = 'green';
formMessage.classList.remove('hidden');
document.getElementById('name').value = '';
document.getElementById('email').value = '';
document.getElementById('surname').value = '';
}
});