The easiest way to do this is to attach the for validation to the submit button. Here's and example:
Your form might look something like this:
<form name="myForm" method="post" action="
onSubmit="return
formValidate(this)">
<input type="text" name="fname"><br>
<input type="text" name="lname">
</form>
and the validation scripot would look like this:
function
formValidate(){
if (document.fname.value.length == 0) {
alert("Please enter your first name"

;
document.fname.focus();
return (false);
}
if (document.lname.value.length == 0) {
alert("Please enter your last name"

;
document.lname.focus();
return (false);
}
}
What this does is test the length of each text box. If the length is 0 then nothing was entered - not even a blank space. Then the focus is placed back on the "offending" element so your user doesn't have to guess at it. If the value is greater than 0, it is assumed that text is entered. You can go further and test for numbers only (like a zip code), for alpha characters only, or a combination of alpah and numeric.
There's always a better way. The fun is trying to find it!