How can I make attachments mandatory when submitting tickets?

To make attachments mandatory when submitting tickets,
I have inserted the following Javascript using the customisation functionality of the customer portal.

An error message is displayed, but event.preventDefault(); does not work and the ticket is created.
Is there any solution to this?


We have had a similar issue with checking our custom ticket field “order reference”, which was mandatory anyways, but we did check with a regex, as our order numbers do always follow a certain logic.

Were not able to prevent the ticket being created. Instead we now deactivate the submit button on incorrect input (and activate again when it is correct).
Kind of a not-so-bad workaround, but would be cool to see your approach working aswell.