-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
72 lines (57 loc) · 1.84 KB
/
script.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
62
63
64
65
66
67
68
69
70
71
72
const form = document.getElementById('registrationForm');
form.addEventListener('submit', (event) => {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (name === '') {
alert('Please enter your name');
return;
}
if (email === '') {
alert('Please enter your email');
return;
}
if (password === '') {
alert('Please enter your password');
return;
}
if (confirmPassword === '') {
alert('Please confirm your password');
return;
}
if (password !== confirmPassword) {
alert('Passwords do not match');
return;
}
// Form data is valid, submit it to the server
form.submit();
});
document.addEventListener('DOMContentLoaded', function () {
// Dropdown menu (mobile)
var dropdown = document.querySelectorAll('.sidenav');
M.Sidenav.init(dropdown);
// Carousel
var carousel = document.querySelectorAll('.carousel');
M.Carousel.init(carousel);
// Modal
var modal = document.querySelectorAll('.modal');
M.Modal.init(modal);
// Form validation
var form = document.querySelectorAll('.validate');
M.FormSelect.init(form);
// Smooth scrolling
var scroll = document.querySelectorAll('a[href^="#"]');
for (var i = 0; i < scroll.length; i++) {
scroll[i].addEventListener('click', function (e) {
e.preventDefault();
var target = this.getAttribute('href');
var targetPosition = document.querySelector(target).offsetTop;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
});
}
});