Skip to content

Instantly share code, notes, and snippets.

@Lonsdale201
Last active November 10, 2024 12:15
Show Gist options
  • Save Lonsdale201/fe4916eb8a7dd73a0931856cb9867de1 to your computer and use it in GitHub Desktop.
Save Lonsdale201/fe4916eb8a7dd73a0931856cb9867de1 to your computer and use it in GitHub Desktop.
JetFormBuilder - Check ajax submit success or other status
// place the code in the child theme functions.php or a custom code snippets plugin like FluentSnippets
// if you want to handle other error statuses, change "invalid_email" to the one you want to monitor.
document.addEventListener( 'DOMContentLoaded', function() {
const { addAction } = window.JetPlugins.hooks;
addAction( 'jet.fb.observe.after', 'test/onSubmit', init );
function init( observable ) {
observable.form.submitter.status.watch( onFormSubmit );
}
function onFormSubmit() {
// If the form success
if ( this.current === 'success' ) {
console.log( 'Form submission successful!' );
alert('Form successfully submitted!');
} else if ( this.current === 'invalid_email' ) {
console.log( 'Form submission failed!' );
alert('Form submission failed! Invail Email issue');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment