JSFiddle - React, Tailwind, and code Playground

HTML

<form name="loginform" action="login" method="post" onSubmit="return validateForm(event);">
<p> Enter user name: <input type="text" name="username"><br>
Enter password: <input name="password" type="password"><br> 
<input type="submit">
</p>
</form>

JavaScript

function validateForm(event)
{
    alert('hello');
    event.preventDefault();
    if(document.loginform.username.value=="")
    {
      alert("User Name can not be left blank");
      document.loginform.username.focus();
      return false;
    }
    else if(document.loginform.password.value=="")
    {
      alert("Password can not be left blank");
      document.loginform.password.focus();
      return false;
    }
    else {
        document.loginform.submit();
    }
}