//or you can use recaptcha as field_callback
$xcrud->field_callback('recaptcha_input','recaptha_function');
function recaptha_function($value, $field, $priimary_key, $list, $xcrud)
{
return '<div class = "form-group col-lg-6">
<div class="g-recaptcha" data-sitekey="MY_KEY"></div>
</div>
<input type = "button" id = "validate_captcha" value = "validate_captcha">';
}
//js example field_js callback
$('#validate_captcha').click(function() {
var captcha = "captcha";
$.ajax({
url: "captcha.php",
method: "post",
data:{captcha:captcha},
success:function(data){
if(data=='success'){
$('form').submit();
}
}
else{
alert('captcha failed. try again');
}
});
});
//if you want you can use your javascript to integrate recaptcha
$xcrud->set_attrib('recaptcha_input',array('id'=>'yourcustomrecaptcha_id','class'=>'g-recaptcha','data-sitekey'=>'MY_KEY'));
//ajax file
<?php
if($_POST['captcha']){
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = 'MY_SECRET_KEY';
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if($data->sucess==true){
echo "success";
}
else{
echo "failed";
}
}
?>