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
Run JavaScript before submit
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?
March 16, 2019 at 11:05 pm
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();
}
March 19, 2019 at 9:39 am
Thank you!
Discussion closed.