I have a Registration form below, and I want to make sure that the users input data into all the fields before pressing submit. If a user does not enter anything, then I want a message box saying ‘You have not completed all fields’. They will only be able to submit their details once they have filled out all the fields. (The field Address2 can be left empty) How would I do this?
Below is the code that I am using for my registration form.
Thanks in advance
<html>
<head>
<SCRIPT language="JavaScript">
<!--
function VerifyData()
{
if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value)
{
alert ("Your passwords do not match - please reenter"
return false;
}
else
return true;
}
-->
</SCRIPT>
<title>Registration Form</title>
</head>
<body>
<input type="button" onClick="document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);" value="ENLARGE TEXT">
<div id="content">
<H1 align="center"><font face="Arial"><u>Registration Form</u></font></H1>
<form action = "adduser1.asp" name="frmUser" method = "post"
onSubmit="return VerifyData()">
Title <input type="text" name = "txtTitle"><br>
First Name <input type="text" name = "txtFirstName"><br>
Surname <input type="text" name = "txtSurname"><br>
Address1 <input type="text" name = "txtAddress1"><br>
Address2 <input type="text" name = "txtAddress2”><BR>
Town <input type="text" name = "txtTown"><br>
County <input type="text" name = "txtCounty"><br>
Post Code <input type="text" name = "txtPostCode"><br>
Telephone Number <input type="text" name = "txtTelephoneNo"><br>
Email Address <input type="text" name = "txtEmailAddress"><br>
Username <input type="text" name = "txtUsername"><br>
Password <input type="password" name = "txtPassword"><br>
Verify Password <input type="password" name = "txtVerifyPassword"><br>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Clear"></font></P>
</form>
<p><font face="Arial"><a href="home.asp">HOME</a></font></p>
</div>
</body>
</html>