I'm trying to add reCaptcha to my Form, but it does't go further than validation. Please help!
I've added the key and I've added the path to /php/recaptachalib.php
but for some reason it doesn't work, when I type captcha or mistype captcha, when I click submit, nothing happens.
reCAPTCHA
<form id="another_form" name="another_form" method="post">
<input type="submit" value="Submit Another Form" />
</form>
<div id="recaptchaModal" title="reCAPTCHA" style="display:none;">
<p>Please fill out this reCAPTCHA to submit this form.</p>
<div id="recaptcha_block"></div>
</div>
<script>
$('form').on('submit', function(e){
e.preventDefault();
var formID = e.currentTarget.id;
$("#recaptchaModal").dialog({
modal: true,
resizable: false,
width: 400,
open: function(e, ui){
Recaptcha.create("your_recaptcha_public_key",
"recaptcha_block",
{
theme: "red",
callback: Recaptcha.focus_resonse_field
}
);
},
close: function(e, ui){
Recaptcha.destroy();
},
buttons: {
"Validate reCAPTCHA": function(){
$.ajax({
url: "/url/to/verify/recaptcha",
type: 'post',
data: {
challenge: Recaptcha.get_challenge(),
response: Recaptcha.get_response(),
additional_data: here
},
success: function(data){
if(data != "success"){
alert("The reCAPTCHA wasn't entered correctly. Please try again.");
Recaptcha.reload();
}
else{
//-- submit your form with AJAX + MVC-style
$.ajax({
url: "/your/submission/url/"+formID,
type: "post",
data: $('#'+formID).serialize(),
success: function(data){
//-- forward user to your thank you page
window.location.href = '/url/to/your/thank/you/page/'+formID;
}
});
}
}
});
},
Cancel: function(){
$(this).dialog("close");
}
}
});
});
</script>
</body>
Captcha is a script that prevents bots from spamming a form i.e. it validates that the agent is a real Human. Secondly, it act as a training for Google’s Machine learning by Identifying Objects in Images
Step 1) Go to https://www.google.com/recaptcha/admin#list.
Step 2) Choose the type of Captcha you want to add.
Step 3) Select the Domain for its usage. For example, indiaedge.in
Step 4) Click Register .
Step 5) Now you will see your site key and secret key .
Step 6) Paste the script tag in the head section of your page.
How to add Captcha in Login Form