Last active
August 29, 2015 13:57
-
-
Save ben-caplan/9355634 to your computer and use it in GitHub Desktop.
Quick hire Honeypot implementation code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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