Hello guys
I have contact popup form and validation script from it
jQuery(document).ready(function($) {
$('.callback-form-container').submit(function() {
var formInputs = $(this).find('.validate');
var errors = '';
$(formInputs).each(function() {
if($.trim(this.value) == '') {
fieldLabel = $(this).parent().find('span.label-text').html();
errors += '- ' + fieldLabel + '\n';
}
});
if(errors.length > 0) {
alert('Input boxes:\n\n' + errors);
return false;
}
else
{
$('.submit-button').val('Wait please');
$('.submit-button').attr('disabled', 'disabled');
return true
}
});
});
});
captcha.php for $.ajax
if(isset($_POST['g-recaptcha-response'])) {
$result = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=6Le(secret code)7O&response=$_POST["g-recaptcha-response"]&remoteip=$_SERVER["REMOTE_ADDR"]'), TRUE);
if($result['success'] == 1) {
console.log("Ok");
} else {
grecaptcha.reset();
}
}
Now I need to integrate invisible reCaptcha. I already have action in my tag that why I can’t add one more and sholud add it to jQuery.
I’ve never have a deal with any captcha before.
As i understand I need 5 steps. I’ve made some attempts to change form but no result.
- Cancel default action (preventDefault?)
- Make button disabled
- Input boxes validation
- Check captcha
- If captcha is ok execute ajax code
Help me please to add recaptcha to my form.