The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Run JavaScript before submit

Labels

This Discussion is public

Notifications

Can you run a JavaScript API call before submit and based on the result either save form data or show an error message if the API call fails? Do I need an additional add-on to make this happen?

You can do it just with jQuery. You can use event.preventDefault() to stop the form submit, run your code, then manually trigger a form submit when your code is successful. The basic function is:

$("#btnSubmit").on("click", function (e) {
e.preventDefault();

/* on success */
$("#form_i2xgme").submit();
}

Thank you!

Discussion closed.