I am creating a JavaScript / ajax comment form using the jQuery Validation Plugin.
How do I customize the messages that are sent to the user? Currently, the form returns heuristic type: NAME_FULL server type: NO_SERVER_DATA field signature: 3489289364 form signature: 13828296746807249018 experiment id:"" when a field is left blank.
I just want it to say “Please enter your name.” Here is the JavaScript that controls the plugin and the form:
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
$(document).ready(function(){
$("#commentForm").submit(function(){
if($("#commentForm").validate()){
$.ajax({
type: 'POST',
url: 'process.php',
data: $(this).serialize(),
success: function(returnedData){
$('#commentForm').append(returnedData);
}
});
}
return false;
});
});
<form class="cmxform" id="commentForm" method="POST" action="">
<fieldset>
<p>
<label for="cname">Name</label>
input id="cname" name="name" size="25" class="required" minlength="2" />
</p>
<p>
<label for="cemail">E-Mail</label>
<input id="cemail" name="email" size="25" class="required email" />
</p>
<p>
<label for="curl">URL</label>
<input id="curl" name="url" size="25" class="url" value="" />
</p>
<p>
<label for="ccomment">Your comment</label>
<textarea id="ccomment" name="comment" cols="22" class="required"></textarea>
</p>
<p>
<input class="submit" type="submit" value="Submit"/>
</p>
And the php is pretty straightforward:
$email = $_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
print "E-mail is correct";
$to = 'asdfdsafasdfsda@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com';
mail($to, $subject, $message, $headers);
} else {
print "E-mail is not correct";
}
EDIT:
Proper implementation of Validation Plugin…
Validation Plugin Documentation