跳到主要内容

SetValidateRange

Sets validate range for field. 💡 Can only be applied to fields with a percentage or number format.

Syntax

expression.SetValidateRange(bGreaterThan, nGreaterThan, bLessThan, nLessThan);

expression - A variable that represents a ApiTextField class.

Parameters

NameRequired/OptionalData typeDefaultDescription
bGreaterThanOptionalbooleanfalseIf true, enables minimum value check using nGreaterThan.
nGreaterThanRequirednumberMinimum allowed value (inclusive or exclusive based on implementation).
bLessThanOptionalbooleanfalseIf true, enables maximum value check using nLessThan.
nLessThanRequirednumberMaximum allowed value (inclusive or exclusive based on implementation).

Returns

boolean

Example

This example gets text field and sets validate range for it.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);

textField.SetNumberFormat(0, "us", "black-minus", "$", true);
textField.SetValidateRange(true, 0, true, 5);
textField.SetValue('10');