How to enable button when text is entered in JavaScript?

To enable a button when text is entered, do this: input.addEventListener('change', e => button.disabled = === '')

So if this is your input and a button:

<input id="my-input">
<button id="my-button" disabled>Click Me</button>

Then you can enable/disable the button based on whether something is in the input with this JavaScript:

document.getElementById("my-input").addEventListener('input', e => {
  document.getElementById("my-button").disabled = === '';