JSFiddle - React, Tailwind, and code Playground

by Stephen

HTML

<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
  var x = document.getElementById("test");
  if (x.value === "") {
    alert("Name must be filled out");
    return false;
  }
  console.log(x);
}
</script>
</head>
<body>

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

</body>
</html>