Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Last active December 15, 2022 11:41
Show Gist options
  • Save johnnyopao/03b44199338feb1745be to your computer and use it in GitHub Desktop.
Save johnnyopao/03b44199338feb1745be to your computer and use it in GitHub Desktop.
<script type="text/javascript">
function yourSubmitFunction(e, $) {
e.preventDefault();
//CUSTOM CODE HERE
// If your code is asynchronous, call this final line in your callback instead
lp.jQuery('.lp-pom-form form').submit();
}
lp.jQuery(function($) {
$('.lp-pom-form .lp-pom-button').unbind('click tap touchstart').bind('click.formSubmit', function(e) {
if ( $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $);
});
$('form').unbind('keypress').bind('keypress.formSubmit', function(e) {
if(e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' && $('.lp-pom-form form').valid() )
yourSubmitFunction(e, $);
});
});
</script>
@johnnyopao
Copy link
Author

Sorry for the super late reply here @honzafelt. Github doesn't send me notifications for my gist scripts.

I'm sure you already have the answer to this or an alternative, but i'll add my response just incase someone else finds this useful.

This script will only allow you to send events after validation which is also before the data gets submitted. This script cannot hook into after submission. For that i'd suggest sending the data event when they land on a unique confirmation page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment