Javascript to stop form submit

<script type="text/javascript">

function validateForm() {

var x = document.forms["validate"]["Username"].value;

if (x == "") {

alert("Username must be filled out");

return false;

}

else

{

return true;

}

}

</script>

<form class="myform" name="validate" id="validate" onsubmit="return validateForm()" action="test.php" method="post">

<input type="hidden" name="loggingIn" value="1">

<input type="text" style='width:300px;color:black;' name="Username" id="Username" placeholder="Username" size="22" maxlength="250" /><br>

<input type="password" style='width:300px;color:black;' name="Password" id="Password" placeholder="Password" size="22" maxlength="250" />

<input class="default-btn btn btn-1" type="submit" onclick="return validateForm();" value="Login Now">

</form>