PDA

View Full Version : Question about an error message on contact form



windbrand
01-04-2012, 05:14 PM
I'm implementing this (http://www.elated.com/res/File/articles/development/javascript/jquery/slick-ajax-contact-form-jquery-php/) contact form on my web page, I've got everything completed except one minor part - I can't customize the form's error messages (the message that pops out if user leaves fields blank or fills incorrect info).
This part of the html handles the error info according to the tutorial:

<div id="sendingMessage" class="statusMessage"><p>Sending your message. Please wait...</p></div>
<div id="successMessage" class="statusMessage"><p>Thanks for sending your message! We'll get back to you shortly.</p></div>
<div id="failureMessage" class="statusMessage"><p>There was a problem sending your message. Please try again.</p></div>
<div id="incompleteMessage" class="statusMessage"><p>Please complete all the fields in the form before sending.</p></div>
However this code is never used in the contact form (you can see the demo on the page I linked, just leave all fields blank and click "send"), instead an image pops up below the fields that needs filling in that says "please fill in this field", as oppoased to the error message in the html that says "lease complete all the fields in the form before sending.". I cannot trace where this image comes from in the code, can anyone see how I can edit this error message?
Thanks.

windbrand
01-05-2012, 05:42 PM
(Starting new post since this will go over character limit for one post)

Html of the page I linked can be seen by "view source".

And the php used (processForm.php) is here, this is the only external file:

<?php

// Define some constants
define( "RECIPIENT_NAME", "ABC" );
define( "RECIPIENT_EMAIL", "ABC@abc.com" );
define( "EMAIL_SUBJECT", "Website visitor message" );

// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";

// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}

// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message!</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message.</p>" ?>
<p>Click your browser's Back button to return to the previous page.</p>
</body>
</html>
<?php
}
?>