I am using jquery validate form script and need to add it a captcha script. if form check returns true,than I want the captcha script to be run to kontrol the entered value by the user. How can I do this? I mean where should I write the captcha check script? thanks.
Form validate is as follows:
$("#form1").validate({
errorPlacement: function(error,element){
return true;
},
errorClass: "invalid"
});
Captcha script is as follows:
$.post("post.php?"+$("#form1").serialize(), {
}, function(response){
if(response==1)
{
$("#after_submit").html('');
$("#Send").after('<label class="success" id="after_submit">Your message has been submitted.</label>');
change_captcha();
clear_form();
}
else
{
$("#after_submit").html('');
$("#Send").after('<label class="error" id="after_submit">Error ! invalid captcha code .</label>');
}
});
You can check the recaptcha code in the submitHandler.
If all the validations are succeeded then the control will reach in the submitHandler and there you can check your recaptcha code.