How to add style to inactive / active button?
That's what i mean
<form> <input type="text"> <input type="submit"> </form> Make a check so that when the text field is filled in, the button is activated and vice versa.
How to add style to inactive / active button?
That's what i mean
<form> <input type="text"> <input type="submit"> </form> Make a check so that when the text field is filled in, the button is activated and vice versa.
var text = document.getElementById('input-text'); var button = document.getElementById('input-button'); text.addEventListener('input', handle); text.addEventListener('keyup', handle); function handle(e) { if (text.value.length >= 5) { button.disabled = false; } if (e.keyCode === 8 || e.keyCode === 46) { if (text.value.length <= 5) { button.disabled = true; } } } <form> <input id="input-text" type="text"> <input id="input-button" type="submit" disabled> </form>