JSFiddle - React, Tailwind, and code Playground

by rdillman

HTML

<form>
  <input type="text" name="name_input" id="user_name" onkeyup="set_submit_status()">
  <button type="submit" id="submit" disabled="true">DOOO ITTTT!</button>
</form>

CSS

button {
  background: green;
  color: white;
}

button:disabled {
  background: red;
}

JavaScript

const set_submit_status = () => {
  const nameInput = document.getElementById('user_name');
  const value = nameInput && !!nameInput.value;
  const send = document.getElementById('submit');
  if (send) {
		send.disabled = !value;
  }
}