I have a form and the client insited on not using lables for the form elements, instead wants to use onBlur/onFocus to show what each form element is for. I believe that this is tampering with the validation of the form elements because it is 1. not able to check if a field has been filled in or not beacuse if is not then it is filled with the input lable and two it does not seem to be validating the email string for correct email syntax. your help is much appreciated.
FORM
FORM PARSE
AGAIN MUCH APPRECIATED!
FORM
Code:
<?php include 'fcf_config.php'; ?>
<div id="contact_form">
<form method="post" action="fcf_parse.php" name="contactform">
<div>
<INPUT
id="name"
onblur="if(this.value==''){this.value=' Name'}"
onfocus="if(this.value==' Name'){this.value=''}"
value=" Name"
title="* Name required"
name="Name" />
</div>
<div>
<INPUT
id="email"
onblur="if(this.value==''){this.value=' Email'}"
onfocus="if(this.value==' Email'){this.value=''}"
value=" Email"
title="* Email required"
class="req"
name="Email" />
</div>
<div>
<INPUT
id="phone"
onblur="if(this.value==''){this.value=' Phone'}"
onfocus="if(this.value==' Phone'){this.value=''}"
value=" Phone"
title="Phone"
name="Phone" />
</div>
<div>
<TEXTAREA
id="comments"
onblur="if(this.value==''){this.value=' Questions'}"
onfocus="if(this.value==' Questions'){this.value=''}"
value=" Questions"
title="* Comments required"
class="req"
name="Comments"
rows="4"
cols="10" /> Questions</TEXTAREA>
</div>
<div>
<p class="form_p">To send your message, please verify your request by answering the simple math question below and then click "Send"</p>
</div>
<p class="form_p"><?php echo $question; ?> <input type="text" class="in_line" id="aplusb" name="answer_out" title="Please enter the answer the math question." />
<input type="hidden" name="answer_p" value="<?php echo $answer_pass; ?>">
<input type="hidden" name="enc" value="<?php echo $enc; ?>"><br /><br />
<div>
<input
id="submit"
type="submit"
class="cfcSub"
value="Send" />
</div>
<p class="form_p">Why do we have verification on our forms? <a href="javascript:void(window.open('captcha_why.html','WHY','resizable=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=350,height=200'))">CLICK HERE</a> to find out why.</p>
</FORM>
<p><a href="<a href="[URL unfurl="true"]http://www.freecontactform.com/"[/URL] id="freecontactform" title="Free Contact Form">Free Contact Form 1.2</a></p>
</div>
FORM PARSE
Code:
<?php
/* YOU DO NOT NEED TO CHANGE ANYTHING IN HERE */
/* BUT FEEL FREE TO IF YOU LIKE, YOU CAN ADD YOUR OWN DESIGN! */
include 'fcf_config.php';
if(isset($_POST['enc'])) {
/* email validation checker */
$the_email = false;
if(eregi("^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", $_POST['Email'])) {
$the_email = true;
} else {
$the_email = false;
}
if(!$the_email || !isset($_POST['Name']) || !isset($_POST['Phone']) || !isset($_POST['Comments'])) {
header("Location: $fail_page");
}
/* validate the encrypted strings */
$dec = false;
$valid = false;
$dec = valEncStr(trim($_POST['enc']), $mkMine);
if($dec == true) {
$valid = true;
} else {
echo "error: $dec <br />";
header("Location: $fail_page");
}
// check the spam question has the correct answer
$ans_one = $_POST['answer_out'];
$ans_two = mkDecStr($_POST['answer_p']);
if($ans_one === $ans_two) {
$valid = true;
} else {
$valid = false;
}
if($valid) {
$email_from = $_POST['Email'];
$email_subject = "Contact from Charlestonlaw.net";
$email_message = "Please find below a message submitted by ";
$email_message .= stripslashes($_POST['Name']);
$email_message .=" on ".date("d/m/Y")." at ".date("H:i")."\n\n";
$email_message .= "Comments: \n";
$email_message .= stripslashes($_POST['Comments'])."\n\n\n";
$email_message .= "Name: \n";
$email_message .= stripslashes($_POST['Name'])."\n\n";
$email_message .= "Phone: \n";
$email_message .= stripslashes($_POST['Phone'])."\n\n";
$email_message .= "Email: \n";
$email_message .= $_POST['Email'];
$headers = 'From: '.$email_from."\r\n" .
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_it_to, $email_subject, $email_message, $headers);
header("Location: $success_page");
die();
}
}
?>
AGAIN MUCH APPRECIATED!