Answers for "js eventlistener to add and remove stylings"

0

js eventlistener to add and remove stylings

const form = document.querySelector('form');
const fname = document.getElementById('fname');
const lname = document.getElementById('lname');
const para = document.querySelector('p');

form.onsubmit = function(e) {
  if (fname.value === '' || lname.value === '') {
    e.preventDefault();
    para.textContent = 'You need to fill in both names!';
  }
}
Posted by: Guest on April-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language