PHP field validation

For displaying the error on the same page, you can do that entirely in JavaScript and not have to deal with the server at all. The exact details will vary, but you can see one approach below:

<html>

<head>
	<title>Form Test</title>
</head>

<body>

	<div id="textContainer">
		<form action="#">
			<input id="nameField" type="text"></input>
			<input id="submitButton" type="Submit"></input>
		</form>
	</div>

	<script>
		var nameField = document.querySelector("#nameField");
		var submitButton = document.querySelector("#submitButton");

		submitButton.addEventListener("click", submitForm, false);

		function submitForm(e) {

			if (nameField.value == "") {
				alert("Value empty!");
				e.preventDefault();
			} else {
				// form submission will just happen
			}
		}
	</script>
</body>

</html>

Hope this helps :stuck_out_tongue: