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

1formInput.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

1const selectedElement = await webflow.getSelectedElement()
2
3const formInputTypes = [
4 'FormCheckboxInput',
5 'FormFileUploadWrapper',
6 'FormRadioInput',
7 'FormSelect',
8 'FormTextarea',
9 'FormTextInput'
10];
11
12if (selectedElement?.type && formInputTypes.includes(selectedElement.type)) {
13 await selectedElement.setRequired(true)
14
15} else {
16 console.log("Selected Element is not a Form Input Element")
17}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnycanvasAny
Built with