bigmex
11-07-2006, 09:52 AM
I need help with this code. I am trying to add a cookie to this form so that when a user completes the form and sends, if they attempt to fill it out again they are directed to an html page stating they already filled out the form. Any help? thanks.
<html>
<head>
<title>My form</title>
<script language="JavaScript">
<!-- Hide the following code
function openDefinitionPage(URL) {
myWindow=window.open(URL,"definition","toolbar=no,width=250, height=250,scrollbars=yes,resize=yes");
}
function validate()
{
if (document.mlist.fname.value=="")
{
alert ("You must fill in all of the required fields!")
return false
}
}
function validate()
{
if (document.mlist.lname.value=="")
{
alert ("You must fill in all of the required fields!")
return false
}
}
function validate()
{
if (document.mlist.addre.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.city.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.state.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.phone.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.email.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.comm.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
// End the hiding here -->
</script>
</head>
<body>
<h1>Join our mailing List!</h1>
*All fields required
<form method="get" name="mlist" onsubmit="return validate()">
<table>
<tr>
<td>First Name:</td>
<td>
<input type="text" name="fname" size="25" maxlength="25" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<input type="text" name="lname" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>Address:</td>
<td>
<input type="text" name="addre" size="50" maxlength="50" />
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="city" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>State:</td>
<td>
<input type="text" name="state" size="2" maxlength="2" />
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input type="text" name="phone" size="10" maxlength="10"/>
</td>
</tr>
<tr>
<td>E-mail Address:</td>
<td>
<input type="text" name="email" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea name="comm" cols="40" rows="8"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Click here to send" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="reset" value="Reset form" />
</td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>My form</title>
<script language="JavaScript">
<!-- Hide the following code
function openDefinitionPage(URL) {
myWindow=window.open(URL,"definition","toolbar=no,width=250, height=250,scrollbars=yes,resize=yes");
}
function validate()
{
if (document.mlist.fname.value=="")
{
alert ("You must fill in all of the required fields!")
return false
}
}
function validate()
{
if (document.mlist.lname.value=="")
{
alert ("You must fill in all of the required fields!")
return false
}
}
function validate()
{
if (document.mlist.addre.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.city.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.state.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.phone.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.email.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
function validate()
{
if (document.mlist.comm.value=="")
{
alert ("You must fill in all the required fields!")
return false
}
}
// End the hiding here -->
</script>
</head>
<body>
<h1>Join our mailing List!</h1>
*All fields required
<form method="get" name="mlist" onsubmit="return validate()">
<table>
<tr>
<td>First Name:</td>
<td>
<input type="text" name="fname" size="25" maxlength="25" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<input type="text" name="lname" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>Address:</td>
<td>
<input type="text" name="addre" size="50" maxlength="50" />
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="city" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>State:</td>
<td>
<input type="text" name="state" size="2" maxlength="2" />
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input type="text" name="phone" size="10" maxlength="10"/>
</td>
</tr>
<tr>
<td>E-mail Address:</td>
<td>
<input type="text" name="email" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea name="comm" cols="40" rows="8"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Click here to send" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="reset" value="Reset form" />
</td>
</tr>
</table>
</form>
</body>
</html>