View Full Version : Trouble with JS Contact Form

06-05-2003, 12:30 AM
I'm trying to set up a contact form on my website that will require users to enter their name, email and choose a reason for the contact from a drop box. I can not get the darn thing to work. Any suggestions would be immensely appreciated. BTW, I'm new to the world of Java, so be gentle. Many thanks, Austin

my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0031)http://ramsites.net/~burgessag/ -->
<HTML><HEAD><TITLE>Contact</TITLE><script language="JavaScript"></script>
<script language="JavaScript">

function validate() {
if(check_validation('current')) {
var response="___________________________________________\n\n";
response += "The form was not submitted due to the following errors.\n";
response += "Please correct these error(s) and re-submit.\n";
response += "___________________________________________\n";

var Tie_Line=/\d{3}-\d{4}/;
var empty_fields ="";

if ( ! Tie_Line.test( f.Tie_Line.value )) {
empty_fields += "\n- Please fill in all required fields";

} else {
return false;
if (empty_fields == "") {
} else {
response += empty_fields + "\n";
return false;
<BODY text=#cc6633 vLink=#333333 aLink=#333333 link=#333333 bgColor=#000000>
<H1 align=center><FONT face=Depot color=#cc6633>The Sound Hole</FONT></H1>
<h2 align=center><span class="contentAreaTitle"><font face="Depot">Contact Me</font></span></h2>
<div align="center">
<table width="39%" border="1" height="553">
<td bgcolor="#cc6633" height="528">
<input type="hidden" name="TARGET_EMAIL" value="burgessag@vcu.edu">
<input type="hidden" name="THANK_YOU" value="http://www.ramsites.net/~burgessag/contact_thankyou.html">
<input type="hidden" name="DATA_FIELDS" value="First_Name,Email,Is_Austin_the_man,Contact_Reason,Comments">
<input type="hidden" name="SURVEY_TITLE" value="Contact Form">
<input type="hidden" name="validation_fields" value="First_Name,Email,Contact_Reason"><span class="contentAreaSubTitle"><font color="#000000">If
you're interested in setting up a trade or a B+P, drop me a line and I'll
let you know what's what. Questions, comments and scathing criticisms
are not only welcome, they're encouraged.</font></span><font color="#000000"><br>
<span class="formRequired">*</span> Indicates a required field.<br>
<span class="formRequired">*</span> First Name:
<input type="text" name="First_Name">
* E-mail Address:
<input type="text" name="Email">
<span class="formRequired">*</span> Who's the man?
<input type="radio" name="email" value="Yes">
<input type="radio" name="email" value="No">
Austin who?<br>
<span class="formRequired">*</span> Now what do you want:
<select name="Contacting_Dept">
<option value="" selected>Select one:</option>
<option value="I wanna trade!">I wanna trade!</option>
<option value="B+P me!">B+P me!</option>
<option value="Dr. Chin is the BOMB!">Dr. Chin is the BOMB!</option>
Comments: Show Details, Feedback, Hate Mail, etc.<br>
<div align="center"></div>
<font color="#000000">
<textarea name="Comments" wrap="virtual" cols="30" rows="5"></textarea>
<input type="submit" value="Submit" onClick="validate();return false;" name="submit">
</font> </td>
<p align="left">&nbsp;</p>
<div align="left"></div>
<div align="left">
<TABLE cellSpacing=0 cellPadding=0 width=403 align=center
<TR align=middle>
<TD bgColor=#cc6633 colSpan=2 height=30>
<DIV align=center><FONT face=Arial color=white size=2><B>[<A
face=Arial color=white size=2><B>[<A
href="mailto:burgessag@vcu.edu">DROP-A-LINE</A>]</B></FONT> </DIV>

06-06-2003, 02:28 AM
It's IE-only. http://www.codingforums.com/images/icons/icon15.gif


Roy Sinclair
06-06-2003, 04:46 PM
This code <input type="submit" value="Submit" onClick="validate();return false;" name="submit"> is incorrect. You are returning a values of false regardless of whether your input was valid or not which causes the submit to be canceled.

You should be returning a value of true from your validation function if everything's ok and your call should be onclick="return validate();" so whatever value is returned by the validate function is passed on to the onclick handler.