HTML Désactiver Soumettre jusqu'à ce que tous les champs requis soient terminés
<!-- HTML inputs -->
<input class="input required" type="text" placeholder="fill me">
<input class="input" type="text" placeholder="fill me">
<input class="input required" type="text" placeholder="fill me">
<button class="button">Click Me</button>
<!-- Js -->
let inputs = document.querySelectorAll('.required'),
button = document.querySelector('.button');
button.disabled = true;
for (i = 0; i < inputs.length; i++) {
inputs[i].addEventListener('input',() => {
let values = []
inputs.forEach(v => values.push(v.value))
button.disabled = values.includes('')
})
}
Clever Cassowary