I needed to ensure that a form field had content before the form was submitted.
Using a JavaScript function with the onSubmit event I was able to check the a field had content before submitting the form.
For a field called firstName add the following into the head of the page
<script type="text/javascript">
<!--
function doSubmit(){
if (formedit.firstName.value.length<1) {
alert("Please provide a first name.")
formedit.firstName.focus();
return false;
}
}
//-->
</script>
Then at the form submit button add a reference to the function. The complete form is as below:
<form id="formedit" action="formSubmit.php" onsubmit="doSubmit();"> <div> First name: <input type="text" name="firstName"></div> <div> Last name: <input type="text" name="lastName"></div> <div><input type="submit" value="Submit"></div> </form>


