julianne26
asked on
COntact Form- Java Script
I have a contact form validator which is java script, i also have an extra validation on the submit button in that form, HOWEVER for some reason that I cannot figure out, the majority of the time, I get forms returned back to me with the proper information.. HOWEVER sometimes i receive BLANK FORMS and this is no good.. i need to see why these forms are allowed to return null values, when I have tried to validate the form twice. Any one can help me that would be GREAT!!
here the the java script from the contactformvalidator.js, if any one sees an error, please let me know, thank you in advance
function Form1_Validator(theForm)
{
if (theForm.first_name.value == "")
{
alert("Please enter a value for the \"First Name\" field.");
theForm.first_name.focus() ;
return (false);
}
if (theForm.last_name.value == "")
{
alert("Please enter a value for the \"Last Name\" field.");
theForm.last_name.focus();
return (false);
}
if (theForm.phone.value == "")
{
alert("Please enter a value for the \"Phone\" field.");
theForm.phone.focus();
return (false);
}
if (theForm.email.value == "")
{
alert("Please enter a value for the \"Email\" field.");
theForm.email.focus();
return (false);
}
if (theForm.best_time_to_cont act.value == "")
{
alert("Please enter a value for the \"Best Time To Contact\" field.");
theForm.best_time_to_conta ct.focus() ;
return (false);
}
if (theForm.address.value == "")
{
alert("Please enter a value for the \"Address\" field.");
theForm.address.focus();
return (false);
}
if (theForm.city.value == "")
{
alert("Please enter a value for the \"City\" field.");
theForm.city.focus();
return (false);
}
if (theForm.state.selectedInd ex < 0)
{
alert("Please select one of the \"State\" options.");
theForm.state.focus();
return (false);
}
if (theForm.state.selectedInd ex == 0)
{
alert("The first \"State\" option is not a valid selection. Please choose one of the other options.");
theForm.state.focus();
return (false);
}
if (theForm.zip_code.value == "")
{
alert("Please enter a value for the \"Zip Code\" field.");
theForm.zip_code.focus();
return (false);
}
if (theForm.zip_code.value.le ngth > 10)
{
alert("Invalid length in the \"Zip Code\" field. Please re-enter.");
theForm.zip_code.focus();
return (false);
}
if (theForm.source.selectedIn dex == 0)
{
alert("Please choose one of the options for how you heard about us.");
theForm.source.focus();
return (false);
}
return (true);
}
here the the java script from the contactformvalidator.js, if any one sees an error, please let me know, thank you in advance
function Form1_Validator(theForm)
{
if (theForm.first_name.value == "")
{
alert("Please enter a value for the \"First Name\" field.");
theForm.first_name.focus()
return (false);
}
if (theForm.last_name.value == "")
{
alert("Please enter a value for the \"Last Name\" field.");
theForm.last_name.focus();
return (false);
}
if (theForm.phone.value == "")
{
alert("Please enter a value for the \"Phone\" field.");
theForm.phone.focus();
return (false);
}
if (theForm.email.value == "")
{
alert("Please enter a value for the \"Email\" field.");
theForm.email.focus();
return (false);
}
if (theForm.best_time_to_cont
{
alert("Please enter a value for the \"Best Time To Contact\" field.");
theForm.best_time_to_conta
return (false);
}
if (theForm.address.value == "")
{
alert("Please enter a value for the \"Address\" field.");
theForm.address.focus();
return (false);
}
if (theForm.city.value == "")
{
alert("Please enter a value for the \"City\" field.");
theForm.city.focus();
return (false);
}
if (theForm.state.selectedInd
{
alert("Please select one of the \"State\" options.");
theForm.state.focus();
return (false);
}
if (theForm.state.selectedInd
{
alert("The first \"State\" option is not a valid selection. Please choose one of the other options.");
theForm.state.focus();
return (false);
}
if (theForm.zip_code.value == "")
{
alert("Please enter a value for the \"Zip Code\" field.");
theForm.zip_code.focus();
return (false);
}
if (theForm.zip_code.value.le
{
alert("Invalid length in the \"Zip Code\" field. Please re-enter.");
theForm.zip_code.focus();
return (false);
}
if (theForm.source.selectedIn
{
alert("Please choose one of the options for how you heard about us.");
theForm.source.focus();
return (false);
}
return (true);
}
Blank forms can be spam that is posted directly to your action page. That skips your validation script completely. What kind of 'action page' do you have?
ASKER
this is the contact page the contact from.. is this what you meant by "action page"?
http://www.carlyleatthepalace.com/contact.html
http://www.carlyleatthepalace.com/contact.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok i am using send_form.php.. is there any code that i need to look for to delete in the php?
ASKER
Here is the PHP code for the send_form.php.. do you see any errors.. or where the spam might be??
<?
$from_name = $HTTP_POST_VARS['first_nam e'];
$from_email = $HTTP_POST_VARS['email'];
$to_name = "Carlyle at The Palace";
$to_email = "gschneider@carlyleonthegr een.net";
$to_emailb = "jkranitz@carlyleonthegree n.net";
$to_emailc = "skirschbaum@carlyleatthep alace.com" ;
$to_emaild = "julie@targetgroupmedia.co m";
$subject = "Carlyle at The Palace Website Submission Form";
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=UTF-8\r \n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\r \n";
$headers .= "Reply-To: \"".$from_name."\" <".$from_email.">\r \n";
$headers .= "X-Priority: 3\r \n";
$headers .= "X-MSMail-Priority: High\r \n";
$headers .= "X-Mailer: Just My Server";
$date = date('d.m.Y');
$message = "<html><head><style type=text/css>body, table, td {font-family: verdana; font-size: 11px; color: #325169; padding: 5px;} </style></head>";
$message .= "<body leftmargin=50px>";
$message .= "<table><tr><td colspan=2 align=center><b>Carlyle at The Palace <br> Website Submission Form</b></td></tr>";
$message .= "<tr><td align=left>First Name:</td><td align=left>".$HTTP_POST_VA RS['first_ name']."</ td></tr>";
$message .= "<tr><td align=left>Last Name:</td><td align=left>".$HTTP_POST_VA RS['last_n ame']."</t d></tr>";
$message .= "<tr><td align=left>Phone:</td><td align=left>".$HTTP_POST_VA RS['phone' ]."</td></ tr>";
$message .= "<tr><td align=left>Email:</td><td align=left>".$HTTP_POST_VA RS['email' ]."</td></ tr>";
$message .= "<tr><td align=left>Best time to Contact:</td><td align=left>".$HTTP_POST_VA RS['best_t ime_to_con tact']."</ td></tr>";
$message .= "<tr><td align=left>Address:</td><t d align=left>".$HTTP_POST_VA RS['addres s']."</td> </tr>";
$message .= "<tr><td align=left>Address 2:</td><td align=left>".$HTTP_POST_VA RS['addres s2']."</td ></tr>";
$message .= "<tr><td align=left>City:</td><td align=left>".$HTTP_POST_VA RS['city'] ."</td></t r>";
$message .= "<tr><td align=left>State:</td><td align=left>".$HTTP_POST_VA RS['state' ]."</td></ tr>";
$message .= "<tr><td align=left>Zip Code:</td><td align=left>".$HTTP_POST_VA RS['zip_co de']."</td ></tr>";
$message .= "<tr><td align=left>Event type Social:</td><td align=left>".$HTTP_POST_VA RS['event_ type_socia l']."</td> </tr>";
$message .= "<tr><td align=left>Event type Corporate:</td><td align=left>".$HTTP_POST_VA RS['event_ type_corpo rate']."</ td></tr>";
$message .= "<tr><td align=left>Event type Other:</td><td align=left>".$HTTP_POST_VA RS['event_ type_other ']."</td>< /tr>";
$message .= "<tr><td align=left>Source:</td><td align=left>".$HTTP_POST_VA RS['source ']."</td>< /tr>";
$message .= "<tr><td align=left>Comments or Questions: </td><td align=left>".$HTTP_POST_VA RS['commen ts']."</td ></tr>";
$message .= "<tr><td> </td><td>&n bsp;</td>< /tr></tabl e></body>< /html>";
mail("$to_name<$to_email>" , $subject, $message, $headers);
mail("$to_name<$to_emailb> ", $subject, $message, $headers);
mail("$to_name<$to_emailc> ", $subject, $message, $headers);
mail("$to_name<$to_emaild> ", $subject, $message, $headers);
?>
<head>
<title>Carlyle at The Palace Website Submission Form</title>
<link href="carlylepalace.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<link href="ie6scrollfix.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type="text/javascript" src="swfobject.js"></scrip t>
<script type="text/javascript" src="contactformvalidator. js"></scri pt>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head >
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td align="center" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="754" height="721" style="background-image:ur l(images/m ain_bg.jpg ); background-repeat:no-repea t;">
<tr>
<td height="94" align="center" valign="top"><img src="images/sendemail_head er.jpg" width="754" height="94" align="top"></td>
</tr>
<tr>
<td align="center" valign="top" style="padding-top:70px">< p class="team_type2"> < /p>
<p class="team_type2">Your request has been sent.</p>
<p><strong><a href="http://www.carlyleatthepalace.com/" class="team_type" id="team_type">Back to Carlyle at The Palace</a></strong></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?
$from_name = $HTTP_POST_VARS['first_nam
$from_email = $HTTP_POST_VARS['email'];
$to_name = "Carlyle at The Palace";
$to_email = "gschneider@carlyleonthegr
$to_emailb = "jkranitz@carlyleonthegree
$to_emailc = "skirschbaum@carlyleatthep
$to_emaild = "julie@targetgroupmedia.co
$subject = "Carlyle at The Palace Website Submission Form";
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=UTF-8\r \n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\r \n";
$headers .= "Reply-To: \"".$from_name."\" <".$from_email.">\r \n";
$headers .= "X-Priority: 3\r \n";
$headers .= "X-MSMail-Priority: High\r \n";
$headers .= "X-Mailer: Just My Server";
$date = date('d.m.Y');
$message = "<html><head><style type=text/css>body, table, td {font-family: verdana; font-size: 11px; color: #325169; padding: 5px;} </style></head>";
$message .= "<body leftmargin=50px>";
$message .= "<table><tr><td colspan=2 align=center><b>Carlyle at The Palace <br> Website Submission Form</b></td></tr>";
$message .= "<tr><td align=left>First Name:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Last Name:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Phone:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Email:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Best time to Contact:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Address:</td><t
$message .= "<tr><td align=left>Address 2:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>City:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>State:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Zip Code:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Event type Social:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Event type Corporate:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Event type Other:</td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td align=left>Source:</td><td
$message .= "<tr><td align=left>Comments or Questions: </td><td align=left>".$HTTP_POST_VA
$message .= "<tr><td> </td><td>&n
mail("$to_name<$to_email>"
mail("$to_name<$to_emailb>
mail("$to_name<$to_emailc>
mail("$to_name<$to_emaild>
?>
<head>
<title>Carlyle at The Palace Website Submission Form</title>
<link href="carlylepalace.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<link href="ie6scrollfix.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type="text/javascript" src="swfobject.js"></scrip
<script type="text/javascript" src="contactformvalidator.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td align="center" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="754" height="721" style="background-image:ur
<tr>
<td height="94" align="center" valign="top"><img src="images/sendemail_head
</tr>
<tr>
<td align="center" valign="top" style="padding-top:70px"><
<p class="team_type2">Your request has been sent.</p>
<p><strong><a href="http://www.carlyleatthepalace.com/" class="team_type" id="team_type">Back to Carlyle at The Palace</a></strong></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
ASKER
also i just found another contactformvalidator in the scripts folder of the ftp, at the end the code the return value is true.. the other conatfromvalidator in the ftp the return value is false.. could this have anything to do with the forms returning blank??
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i am confused when you say don't send the emails if its spam.. i don't want to send emails, I just want to make sure the form we have on our website is is being validated correctly. If there is an issue with spam, then i want to know how to solve the issue that will make the form validate the right way. I will take your suggestion and replace the $HTTP_POST_VARS with $_POST, will this solve the issue i am having with our clients receiving blank forms.. bc they are livid.. and I am trying to trouble shoot this the best that I can, thanks for all your help so far...
You really should have only one 'contactformvalidator' just to eliminate confusion. I suppose if your page was getting the wrong one, it could be part of your problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
GREAT feed back!! one more question.. i am going to delete one of the validation java script forms... but i need to know which one... the first java script returns the value true at the end of the code (the code i pasted above).. and the other java script returns false.. which one should i keep?
The one you posted above looks fine to me. It has 'return false' on all the errors and 'return true' if there aren't and that's what you want.