Ive been looking through a whole tonne of sites to try to find out how I can make my fields mandatory but havnt been able to find something so far which actually tells me whwta I want to know. Ive tried a couple of code segments but they havnt been working. can anyone tell me how I can make fields in my code mandatory?
My attempt at solving this is below:
My attempt at solving this is below:
Code:
<html>
<head>
<title>Coals Spiral Brochure Enquiry Form</title>
<meta name="description" content="">
<meta name="keywords" content="">
<script language="javascript"
type="text/javascript">
function validateForm(brochure1)
{
if(""==document.forms.brochure1.firstname.value)
{
alert("Please enter your first name.");
return false;
}
if(""==document.forms.brochure1.lastname.value)
{
alert("Please enter your last name.");
return false;
}
if(""==document.forms.brochure1.email.value)
{
alert("Please enter your email address.");
return false;
}
}
if(""==document.forms.brochure1.phone.value)
{
alert("Please enter your Phone number.");
return false;
}
}
if(""==document.forms.brochure1.country.value)
{
alert("Please enter your country.");
return false;
}
}
</script>
</head>
<body bgcolor="white" text="black">
<table width="60%" align="center">
<tr>
<td>
<font face=Arial size=2>
<IMG SRC="http://www.mdmintec.reachpoint.com/Data/mdmintec/Roche%20MT%20sm.jpg" align="right">
<strong><BR><BR><BR><BR><BR>
Coals Spiral Brochure Enquiry Form</strong>
<HR style="WIDTH: 100%; HEIGHT: 1px" align=center width="100%" color=black>
<BR>
Please fill out your details below in order to receive our Coals Spiral Brochure.
<BR><BR>
<form method="post" onsubmit='return validateForm()' action="http://svr86.ehostpros.com/~minera86/brochure1.php">
<TABLE width=85% align=center cellSpacing=1 cellPadding=1 border=0>
<TR>
<TD>
<font face=Arial size=2>First Name:
</TD>
<TD>
<INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill" maxLength=100 size=40 name=firstname>
</TD>
</TR>
<TR>
<TD>
<font face=Arial size=2>Last Name:
</TD>
<TD>
<INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill" maxLength=100 size=40 name=lastname>
</TD>
</TR>
<TR>
<TD>
<font face=Arial size=2>Email:
</TD>
<TD>
<INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill" maxLength=100 size=40 name=email>
</TD>
</TR>
<TR>
<TD>
<font face=Arial size=2>Phone:
</TD>
<TD>
<INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill" maxLength=100 size=40 name=phone>
</TD>
</TR>
<TR>
<TD>
<font face=Arial size=2>Country: <BR><BR><BR><BR>
</TD>
<TD>
<INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill" maxLength=100 size=40 name=country>
<p Align=right>
<input class="BButton" value="Send" name="cmdSubmit" type="submit">
</align>
</TD>
</TR>
</TABLE>
</form>
</font>
</body>
</html>
Comment