Last active
December 15, 2022 11:41
-
-
Save johnnyopao/03b44199338feb1745be to your computer and use it in GitHub Desktop.
This file contains 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 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.