JSFiddle - React, Tailwind, and code Playground

by Stephen

HTML

<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
  var x = document.getElementById("nameTest");
  if (x.value === "") {
    alert("Name must be filled out");
    return false;
  }
  console.log(x);
  // Always prevent the form form being submitted, since this
  // is a fiddle with no place for the submit to go.
  return false;
}
</script>
</head>
<body>

<!-- <form name="myForm" action="/action_page.php\" onsubmit="return validateForm()" method="post"> -->
<form name="myForm" method="post">
  Name: <input type="text" name="nameTest">
  <button type="submit" value="Submit" onclick="return validateForm()">Click me</button>
</form>

</body>
</html>

CSS

body { background-color: white; }