Skip to content

Instantly share code, notes, and snippets.

@ben-caplan
Last active August 29, 2015 13:57
Show Gist options
  • Save ben-caplan/9355634 to your computer and use it in GitHub Desktop.
Save ben-caplan/9355634 to your computer and use it in GitHub Desktop.
Quick hire Honeypot implementation code
<script>
jQuery(function($){
$('#contactForm')
.off()
.on('honeypotBeforeSend', function(e, xhr, s){
comments = $(this).find('textarea[name="comments"]');
s.data = s.data.replace( /comments=(.|\s)*?&/, 'comments='+encodeURIComponent(comments.val()+' \n\n '+ window.YOUR_VAR + ' (Request from this page: http://${request.getServerName()}${VTLSERVLET_URI}) ')+'&' );
})
.honeypot({
formParent : '#formWrapper',//enter your form's parent (this adds the "thinking" class)
elContainingResponseHTML : '#response',//where the responce text is located in the AJAX requested page - aka, the form's action
elToReplaceWithResponseHTML : '#formWrapper',//what element on current page do you want to overwrite?
sendingClass : 'sending',//class that will be added to elContainingResponseHTML
gaTrackingCode : 'UA-684147-1',//tracking code
gaHiddenFieldSelector : '#ga_page_url'//hidden input field that has the GA id
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment