1const form = document.querySelector('form');
2const fname = document.getElementById('fname');
3const lname = document.getElementById('lname');
4const para = document.querySelector('p');
5
6form.onsubmit = function(e) {
7 if (fname.value === '' || lname.value === '') {
8 e.preventDefault();
9 para.textContent = 'You need to fill in both names!';
10 }
11}