JSFiddle - React, Tailwind, and code Playground
by NicoO
HTML
<form id="form" name="input" method="post" action="mytarget.php">
<input id="userinput" name="userinput" type="text" />
<input id="submit" type="submit" value="submit" />
</form>
JavaScript
var form = document.getElementById("form");
form.addEventListener("submit", function(event){
console.log("test");
var name = form.elements['userinput'].value;
if(name.length < 3){
alert("boy your name is short!");
event.preventDefault();
}
});