Mautic Community Forums

Extending form JavaScript

Does anyone know if it’s possible to add to or customise JavaScript which runs when a form is submitted, preferably via a plugin or a theme?

I’m not trying to make any big changes, just add / remove css classes once a form has been submitted, and once the response comes back from the server to display the confirmation message.

Example - forms loaded on a website via the automatic script tag

<script type="text/javascript" src="//[SITE_URL]/form/generate.js?id=[FORM_ID]"></script>

Form loads - add css class to form
Form submitted - add / remove css classes
Form confirmation/server response - add / remove css classes

Any advice would be appreciated.

Many Thanks