Unable to assign onsubmit attribute to my form

I’m trying to assign a custom attribute to my form which is onsubmit, but it prevents me to do so and says that its a reserved name

Webflow reserves some custom attributes.
You can still override these using javascript.

However for an onsubmit, it’s considered best practice to attach event handlers programmatically using JavaScript, rather than embedding them directly in your HTML markup.

You can do that by giving your form an ID like myForm, and then adding this to your before BODY custom code.

var form = document.getElementById('myForm');
form.addEventListener('submit', function(event) {

  // Do whatever