Hi all,
I'm having a problem with another piece of Javascript code
. This code is actually a validation script that evaluates information that is entered into the form before the form is submitted. I've got the main code already set up to fire when the user hits the submit button. The problem I'm having is with this code:
}
// Check for City
if (this form.City.value=="")
}
alert("You must enter in a city");
thisform.City.focus();
return false;
This is the rest of the code that I already have
<html>
<head>
<title>Adam Smith for Congress 2000 Campaign Site -- Make a Contribution Today </title>
<script language="Javascript">
<!--
function validation(thisform)
{
// Check for First Name.
if (thisform.FirstName.value=="")
{
alert("The First Name field is required. The form will not be submitted until you correct the error");
thisform.FirstName.focus();
return false;
}
// Check for Last Name.
if (thisform.LastName.value=="")
{
alert("The Last Name field is required. The form will not be submitted until you correct the error");
thisform.LastName.focus();
return false;
}
// Check for City
if (this form.City.value=="")
}
alert("You must enter in a city");
thisform.City.focus();
return false;
return true
}// function validation()
-->
</script>
</head>
<BODY vlink="black" link="black" bgcolor="white">
<form method="post" onSubmit="return validation(this)" action="http://matcmadison.edu/faculty/jjones/ITIP/post-echo.asp">
<table border="1" width="400" cellpadding="5" cellspacing="5" align="left">
<tr>
<td align="left" bgcolor="#fffff0">
<p align="left">
To make an on-line contribution now, please fill out the form below and press
the submit button. The information and the amount of your contribution will be
sent directly to the Smith for Congress Campaign.
</p>
</td>
</tr>
<tr>
<td align="left" bgcolor="#000099">
<p align="right">
First Name*: <input name="FirstName" size="35" maxlength="50"><br>
Last Name*: <input name="LastName" size="35" maxlength="50"><br>
Address: <input name="Address" size="35" malenght="40"><br>
City: <input name="City" size="35"><br>
State: <input name="State" value="CA" size="2" maxlength="2">
Zipcode: <input name="Zip" size="12" maxlength="14"><br>
Country: <input name="Country" value="US" size="35" maxlength="2"><br>
Employer: <input name="Employer" size="35" maxlength="50"><br>
Occupation: <input name="Occupation" size="35" maxlength="50"><br>
Phone: <input name="Phone" size="35" maxlength="13"><br>
Email Address: <input name="Email" size="35"><br>
Credit Cards Accepted<select name="Credit Card" size="1">
<option selected value="Visa">Visa</option>
<option value="MasterCard">MasterCard</option>
<option value="Discover">Discover</option>
<option value="American Express">American Express</option>
</select><br>
Credit Card #: <input name="CreditCard#" size="15" maxlength="9"><br>
<br>
Expires
<select name="Month" size="1">
<option selected value="Month">Month</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="Year" size="1">
<option selected value="Year">Year</option>
<option value="2005">2005</option>
<option value="2007">2007</option>
<option value="2010">2010</option>
<option value="2012">2012</option>
</select><br>
Name On Credit Card:<input name="NameOnCard" size="35"><br>
<p>
I would like to make a contribution of:
<P align="left">
$ <input name="ContributionAmt" size="15"> (Minimum $5, Maximum $1000)
</P>
<P align="center">
<input type="submit" name="submit" value="Submit"> <input type="reset" value="Reset">
<p align="left">*= fields marked with an asterisk are required in order to submit
the form information successfuly</p>
</td>
</tr>
<tr>
<td align="left" bgcolor="#fffff0">
<P align="left">If you prefer to send a contribution by check, please make it
payable to Adam Smith for Congress and send it to:<br>
<br>
Smith for Congress<br>
35 S. Raymond Avenue, Suite 206<br>
Pasadena, CA 91105
</P>
</td>
</tr>
</table>
</form>
</BODY>
</html>
I did not expect any problems after I finished coding the City validation snippet. The testing revealed bad news. When I hit the submit button after I filled out only one field, I came right to the confirmation page. The validation script didn't even fire like it did before I even coded the city function because the new code (somehow) had overridden it.
I'd appreciate any help,
Thanks,
Ben
Ben
Madison Area Technical College student
-------------------------
I am one of those people that you call "Microsoft Access Freaks". I'm addicted to Access