Edit this page

up.form up:form:submit
DOM event

This event is emitted when a form is submitted through Unpoly.

When the form is being validated, this event is not emitted. Instead an up:form:validate event is emitted.

Changing render options

Listeners may inspect and manipulate render options for the coming fragment update.

The code below will use a custom transition when a form submission fails:

up.on('up:form:submit', function(event) {
  event.renderOptions.failTransition = 'shake'
})

Submission

event.form
required

The form that is being submitted.

event.params
required

The form parameters that will be send as the form's request payload.

Listeners may inspect and modify params before they are sent.

[event.submitButton]
optional

The button used to submit the form.

If no button was pressed directly (e.g. the user pressed Enter inside a focused text field), this returns the first submit button.

If the form has no submit buttons, this property is undefined.

event.target
required

The element that caused the form submission.

This is usually a submit button or a focused field from which the user pressed Enter. If the element is not known, the event is emitted on the <form> element.

Render pass

event.renderOptions
required

An object with render options for the fragment update.

Listeners may inspect and modify these options.

event.preventDefault()
required

Prevents the form from being submitted.