-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
25 lines (22 loc) · 975 Bytes
/
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
/*Проверяем форму, если все заполнено отправляет*/
document.getElementById('sendbutton').addEventListener('click', function() {
var name = document.getElementById('nname').value;
var email = document.getElementById('mail').value;
var phone = document.getElementById('pphone').value;
var message = document.getElementById('iinfo').value;
if (name === '' || email === '' || phone === '' || message === '') {
alert('Please fill in all fields.');
} else {
document.getElementById('myForm').submit();
alert('Your message has been sent!');
}
});
/*Добавляем smooth scroll к якорным ссылкам*/
document.querySelectorAll('a[href^="#"]').forEach(anchor=> {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth"
});
});
});