Skip to main content

Form

<sc-form></sc-form>

This component let users create an form container.

Submit

Component Codex

Properties

PropertyDescriptionTypeDefault
novalidatePrevent the form from validating inputs before submitting.booleanfalse

Events

EventDescriptionType
scFormChangeEmitted when the form is submitted. This event will not be emitted if any form control inside of it is in an invalid state, unless the form has the `novalidate` attribute. Note that there is never a need to prevent this event, since it doen't send a GET or POST request like native forms. To "prevent" submission, use a conditional around the XHR request you use to submit the form's data with.CustomEvent<Object>
scFormSubmitBackwards compat.CustomEvent<void>
scSubmitEmitted when the form is submitted. This event will not be emitted if any form control inside of it is in an invalid state, unless the form has the `novalidate` attribute. Note that there is never a need to prevent this event, since it doen't send a GET or POST request like native forms. To "prevent" submission, use a conditional around the XHR request you use to submit the form's data with.CustomEvent<void>

Methods

getFormData() => Promise<FormData>

Serializes all form controls elements and returns a `FormData` object.

getFormJson() => Promise<Record<string, unknown>>

submit() => Promise<void>

validate() => Promise<boolean>

Shadow Parts

PartDescription
base
form