am working with a form that has recaptcha and its validated with jquery, everything works perfectly fine *the info is sent to my email and all required field are checked before been send)
the only one problem am facing is that once the info is sent and all fields are reset the error messages are visible
only way they are hidden is if page is i change in the js “reset” instated of “clear” but this refresh the pagge and the thank u message isnt visible anymore.
(i know maybe all sounds bit confiusing)
this is the code what am talking
function validateCaptcha(){
challengeField = $("input#recaptcha_challenge_field").val();
responseField = $("input#recaptcha_response_field").val();
nameField = $("input#name").val();
emailField = $("input#email").val();
phoneField =$("input#phone").val();
reasonField =$("input#reason").val();
messageField =$("textarea#message").val();
var html = $.ajax({
type: "POST",
url: "ajax.recaptcha.php",
data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField +"&name="+ nameField +"&email=" + emailField +"&phone="+ phoneField + "&reason=" + reasonField +"&message=" + messageField,
async: false
}).responseText;
if(html == "success")
{
$('#contactForm').each (function(){
this.reset();
Recaptcha.reload();
})
$("#thanks").html("Thank you");
return false;
}
else
{
$("#captchaStatus").html("Your captcha is incorrect. Please try again");
Recaptcha.reload();
return false;
}
}
Use a reset button to clear the form feilds.