javascript form submit on button click check if required fields not empty
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 />
Also in JavaScript:
- react admin newrecords.foreach is not a function
- Root composer.json requires farhanwazir/laravelgooglemaps dev-master -> satisfiable by farhanwazir/laravelgooglemaps[dev-master].
- extract all link with javascript
- convert date to string javascript
- how to remove a property from an object in javascript
- react native layout animation
- checkbox is checked jquery
- js split array into smaller arrays
- How to Submit Forms and Save Data with React.js
- How do you call a functional component in React
- jquery when you typing in input
- check if javascript function is true
- jquery move element to another without losing events
- crear componente con angular cli
- js show span for 5 seconds
- how to generate random string in node js
- sort by attribute in reactjs
- remove object from array javascript
- ionic modal navbar not showing
- javascript limit input to 2 decimal places
- node.js wikipedia api call
- javascript get current month start and end date
- html js drag image with mouse
- jquery links