View Full Version : IF statements

12-12-2006, 06:23 PM
I am trying to find how to do the following:

if Field 1 is completed


Field 2 must be filled out.

I remember an online site that showed me, but I cant find it.

12-13-2006, 12:14 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form validation</title>
<script type="text/javascript" language="javascript">
function validate() {
var theForm = document.myForm;

if(theForm.theFirstField.value.length > 1 && theForm.theSecondField.value.length == 0) {
alert("Please fill in the second field");
return false;

alert("The form is ok to submit.");
return true;

<form name="myForm" method="post" action="?" onsubmit="return validate();">

<p>First field:<br /><input type="text" name="theFirstField" /></p>
<p>Second field:<br /><input type="text" name="theSecondField" /></p>

<input type="submit" name="theSubmit" value="Submit" />
</html>Hope this helps.


12-13-2006, 06:17 PM
Awesome Thank you!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum