Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation Check

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
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=&quot;JavaScript&quot;>
<!--
function VerifyData()
{
if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value)
{
alert (&quot;Your passwords do not match - please reenter&quot;);
return false;
}
else
return true;
}
-->
</SCRIPT>

<title>Registration Form</title>
</head>
<body>

<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;ENLARGE TEXT&quot;>
<div id=&quot;content&quot;>

<H1 align=&quot;center&quot;><font face=&quot;Arial&quot;><u>Registration Form</u></font></H1>

<form action = &quot;adduser1.asp&quot; name=&quot;frmUser&quot; method = &quot;post&quot;
onSubmit=&quot;return VerifyData()&quot;>

Title <input type=&quot;text&quot; name = &quot;txtTitle&quot;><br>
First Name <input type=&quot;text&quot; name = &quot;txtFirstName&quot;><br>
Surname <input type=&quot;text&quot; name = &quot;txtSurname&quot;><br>
Address1 <input type=&quot;text&quot; name = &quot;txtAddress1&quot;><br>
Address2 <input type=&quot;text&quot; name = &quot;txtAddress2”><BR>
Town <input type=&quot;text&quot; name = &quot;txtTown&quot;><br>
County <input type=&quot;text&quot; name = &quot;txtCounty&quot;><br>
Post Code <input type=&quot;text&quot; name = &quot;txtPostCode&quot;><br>
Telephone Number <input type=&quot;text&quot; name = &quot;txtTelephoneNo&quot;><br>
Email Address <input type=&quot;text&quot; name = &quot;txtEmailAddress&quot;><br>
Username <input type=&quot;text&quot; name = &quot;txtUsername&quot;><br>
Password <input type=&quot;password&quot; name = &quot;txtPassword&quot;><br>
Verify Password <input type=&quot;password&quot; name = &quot;txtVerifyPassword&quot;><br>

<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;>&nbsp;
<INPUT TYPE=&quot;RESET&quot; VALUE=&quot;Clear&quot;></font></P>
</form>
<p><font face=&quot;Arial&quot;><a href=&quot;home.asp&quot;>HOME</a></font></p>

</div>
</body>
</html>



 
try forum216 for client side scripting questions

_____________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top