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

1

if input value is null do something

if(document.getElementById("question").value.length == 0)
{
    alert("empty")
}
Posted by: Guest on April-04-2020
0

javascript form submit on button click check if required fields not 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'); 
  }
});
Posted by: Guest on January-24-2021
4

how to check if all inputs are not empty with javascript

const inputFeilds = document.querySelectorAll("input");

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

console.log(validInputs) //[array with valid inputs]
Posted by: Guest on December-17-2020
0

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

<input type="text" id="checkIt" required />
Posted by: Guest on January-24-2021

Code answers related to "javascript form submit on button click check if required fields not empty"

Code answers related to "Javascript"

Browse Popular Code Answers by Language