if input is empty javascript code example
Example 1: if input value is null do something
if(document.getElementById("question").value.length == 0)
{
alert("empty")
}
Example 2: 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)
Example 3: javascript check if empty
if (typeof myVar === 'undefined'){
console.log("I am not defined");
}
var emptyString="";
if (emptyString) {
console.log("im not empty");
}