<form id="myform" method="post" action="test.php">
<input id="email" type="text" name="email" />
<div id="recap"></div> <div id="err" class="hidden"
style="background-color:#FFFF00;color:#FF0000;margin:12px
0px 12px 0px;">The Captcha wasn't entered correctly.
Please try again.</div> <input id="myform-submit"
type="submit"
value="Validate!">
</form>
Here is code for jquery email validation:
$(document).ready(function(){
$("#myform").validate({
rules: {
email : {
required : true, email : true }
},
submitHandler : recapVerify }); });
Function recapVerify will be called submitHandler : recapVerify
after email was validated, here is code:
function recapVerify(form){
#console.log(form);
#alert("in submit handler");
$.ajax({ type:'post', url: 'captcha_check.php',
data: { recaptcha_challenge_field:
$('#recaptcha_challenge_field').val(),
recaptcha_response_field:
$('#recaptcha_response_field').val() }
}).done(function(data, textStatus, jqXHR)
{ if (data == 'success'){ $('#err').addClass('hidden');
//document.forms[0].submit(); // uncomment this line
to submit your form
alert('Success, the form and reCAPTCHA validated, your
form was submitted'); }
else { $('#err').removeClass('hidden'); }
}).fail(function(jqXHR,textStatus,errorThrown)
{ console.log('proxy or service failure'); }); }
// WHEN CALLED THIS
INSETS THE reCAPTCHA INTO THE PAGE
function reCapInsert(){
Recaptcha.create('6LfPK_kSAAAAAP6qLxQkrUBPOLLlrV9HFrTBJQQq',
// public key 'recap',
{ theme: 'white',
callback: Recaptcha.focus_response_field } );
}
// WHEN THE DOM HAS LOADED FIRE THE reCapInsert FUNCTION TO
INSERT THE reCAPTCHA
$( document ).ready(function(){ reCapInsert(); });
Function recapVerify() gets called but no recaptcha verification will happen? I am not straightforward with jquery and javascript so I can't figure out what the problem might be. Any suggestion?