Set Required Status

formInput.setRequired(value)

Sets the required status of a form input.

This method is applicable to the following form input types:

  • FormCheckboxInput
  • FormFileUploadWrapper
  • FormRadioInput
  • FormSelect
  • FormTextarea
  • FormTextInput

Syntax

formInput.setRequired(value: boolean): Promise<null>

Parameters

  • value: Boolean - The required status of the form input.

Returns

Promise<null>

A Promise that resolves to null.

Example

const selectedElement = await webflow.getSelectedElement()
const formInputTypes = [
'FormCheckboxInput',
'FormFileUploadWrapper',
'FormRadioInput',
'FormSelect',
'FormTextarea',
'FormTextInput'
];
if (selectedElement?.type && formInputTypes.includes(selectedElement.type)) {
await selectedElement.setRequired(true)
} else {
console.log("Selected Element is not a Form Input Element")
}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnycanvasAny