Skip to main content

SetRequired

Specifies if the current form should be required.

Inherited from ApiFormBase.SetRequired.

Syntax​

expression.SetRequired(bRequired);

expression - A variable that represents an ApiTextForm class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
bRequiredRequiredbooleanDefines if the current form is required (true) or not (false).

Returns​

boolean

Example​

Mark a text form as required in a document.

// How do I make a text form mandatory for the user to fill out in a document?

// Enforce completion of a text form before the document can be submitted in a document.

let doc = Api.GetDocument();
let textForm = Api.CreateTextForm({"key": "Personal information", "tip": "Enter your first name", "placeholder": "First name", "comb": true, "maxCharacters": 10, "cellWidth": 3, "multiLine": false, "autoFit": false});
let paragraph = doc.GetElement(0);
paragraph.AddElement(textForm);
textForm.SetRequired(true);
let required = textForm.IsRequired();
paragraph = Api.CreateParagraph();
paragraph.AddText("The first form from this document is required: " + required);
doc.Push(paragraph);