javascript form submit on button click check if required fields not empty

JavaScript
if(document.getElementById("question").value.length == 0)
{
    alert("empty")
}const checkEmpty = document.querySelector('#checkIt');
checkEmpty.addEventListener('input', function () {
  if (checkEmpty.value && // if exist AND
    checkEmpty.value.length > 0 && // if value have one charecter at least
    checkEmpty.value.trim().length > 0 // if value is not just spaces
  ) 
  { console.log('value is:    '+checkEmpty.value);}
  else {console.log('No value'); 
  }
});const inputFeilds = document.querySelectorAll("input");

const validInputs = Array.from(inputFeilds).filter( input => input.value !== "");

console.log(validInputs) //[array with valid inputs]<input type="text" id="checkIt" required />
Source

Also in JavaScript: