Skip to main content

SetValidateRange

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

Syntax​

expression.SetValidateRange(greaterThan, greaterThanValue, lessThan, lessThanValue);

expression - A variable that represents a ApiComboboxField class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
greaterThanOptionalbooleanfalseIf true, enables minimum value validation using greaterThanValue.
greaterThanValueRequirednumberThe minimum allowed value.
lessThanOptionalbooleanfalseIf true, enables maximum value validation using lessThanValue.
lessThanValueRequirednumberThe maximum allowed value.

Returns​

boolean

Example​

Limit field values to a numeric range in a PDF.

// Can I restrict numbers to a minimum and maximum in a PDF?

// Accept only numbers within specified bounds in a PDF.

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

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