I set up a custom form template using Sprout Forms and added {{ craft.sproutInvisibleCaptcha.protect() }}
inside the <form>
tag.
I can see there are several captcha tags added by the plugin, but as I am using AJAX submission:
- How can I make it works using this submission method?
- How do I handle redirect to my 'redirect' location?
I did these tests:
- Prevent a form from being submmitted if a user does not have JavaScript enabled ;
- Block form submissions by robots who auto-fill all of your form fields ;
- Require minimum time to fill out your form ;
All of these tests have failed, spam haven't been caught.
This is the captcha field inside custom Sprout Form template:
{{ craft.sproutInvisibleCaptcha.protect() }}
<input type="hidden" name="redirectOnFailure" value="{{ craft.request.getUrl() }}">
And this is the AJAX post inside JS script:
var postUrl = 'sproutForms/entries/saveEntry',
formData = {
action: postUrl,
handle: 'test',
fields: {}
};
formData['fields[minPrice]'] = $scope.results.minPrice;
formData['fields[maxPrice]'] = $scope.results.maxPrice;
formData = $.param(formData);
$.ajax({
type : 'POST',
url : postUrl,
data : formData,
dataType : 'json',
encode : true
});
formData
does not even contain all the required fields from sproutForms. The plugin injects your form with several fields -> it adds much content to the form but you only send 2 of them to the plugin -> the plugin does not recognize the protection. you'll need to send all fields in your ajax request. Make a$('#formId').serialize();
or look for every single field in your form manually.