-
-
Save Lonsdale201/fe4916eb8a7dd73a0931856cb9867de1 to your computer and use it in GitHub Desktop.
JetFormBuilder - Check ajax submit success or other status
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
// 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