JSFiddle - React, Tailwind, and code Playground

HTML

<form name="savegameform" method="post" action="submitsave.php" onSubmit="return validateForm(); return false;"><p>
<span class="formline">Name: </span><input type="text" name="username" size="25"><br />
//More of the form
<input type="submit" name="submit" value="Submit">

<span id="JSError">Test.</span>

    </p></form>

JavaScript

function validateForm() {
    var x = document.forms["savegameform"]["username"].value;
    if (x == null || x == "") {
        document.getElementById("JSError").innerHTML = "Error: Please enter a name."; 
        return false;
    } else {
    return true;
    }

    alert("Bla");
}