# TextField

## Content

[**DsPdfJS API v9.1.3**](../README)

***

[DsPdfJS API](../globals) / TextField

# Class: TextField

Represents a text field.

## Extends

- [`Field`](Field)

## Extended by

- [`CombTextField`](CombTextField)

## Constructors

### Constructor

> **new TextField**(`om`): `TextField`

Creates a new TextField.

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

[ObjectManager](ObjectManager) that controls the lifetime of the TextField.

#### Returns

`TextField`

#### Overrides

`Field.constructor`

### Constructor

> **new TextField**(): `TextField`

Creates a new TextField.

#### Returns

`TextField`

#### Overrides

`Field.constructor`

## Accessors

### alternateName

#### Get Signature

> **get** **alternateName**(): `string` \| `null`

Gets or sets an alternate field name to be used in place of the actual field name wherever
the field must be identified in the user interface (such as in error or status messages referring to the field).
This text is also useful when extracting the document's contents in support of accessibility
to users with disabilities or for other purposes.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **alternateName**(`value`): `void`

Gets or sets an alternate field name to be used in place of the actual field name wherever
the field must be identified in the user interface (such as in error or status messages referring to the field).
This text is also useful when extracting the document's contents in support of accessibility
to users with disabilities or for other purposes.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`alternateName`](Field#alternatename)

***

### calculationIndex

#### Get Signature

> **get** **calculationIndex**(): `number`

Gets or sets an index that is used to determine the field's calculation order.
Fields with lower indices are calculated before fields with higher indices.

If several fields have the same CalculationIndex, the calculation order is determined
by the order of fields in the collection.

[recalculateValue](Field#recalculatevalue) can be used to specify JavaScript that is used to calculate the field's value.

##### Returns

`number`

#### Set Signature

> **set** **calculationIndex**(`value`): `void`

Gets or sets an index that is used to determine the field's calculation order.
Fields with lower indices are calculated before fields with higher indices.

If several fields have the same CalculationIndex, the calculation order is determined
by the order of fields in the collection.

[recalculateValue](Field#recalculatevalue) can be used to specify JavaScript that is used to calculate the field's value.

##### Parameters

###### value

`number`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`calculationIndex`](Field#calculationindex)

***

### children

#### Get Signature

> **get** **children**(): [`FieldCollection`](FieldCollection)

Gets the list of child fields.

##### Returns

[`FieldCollection`](FieldCollection)

#### Inherited from

[`Field`](Field).[`children`](Field#children)

***

### defaultStyleString

#### Get Signature

> **get** **defaultStyleString**(): `string` \| `null`

Gets or sets the default style string used when the field value is specified using [TextField#richTextValue](#richtextvalue).
See PDF specification for details.
Note that DsPdfJS does not automatically regenerates appearance streams for text fields containing RTF text.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **defaultStyleString**(`value`): `void`

Gets or sets the default style string used when the field value is specified using [TextField#richTextValue](#richtextvalue).
See PDF specification for details.
Note that DsPdfJS does not automatically regenerates appearance streams for text fields containing RTF text.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

***

### defaultText

#### Get Signature

> **get** **defaultText**(): `string` \| `null`

Gets or sets the default text of this TextField,
applied when the field is reset.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **defaultText**(`value`): `void`

Gets or sets the default text of this TextField,
applied when the field is reset.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

***

### defaultValue

#### Get Signature

> **get** **defaultValue**(): `string` \| `number` \| `boolean` \| `number`[] \| `null`

Gets or sets the field's default value.

##### Returns

`string` \| `number` \| `boolean` \| `number`[] \| `null`

#### Set Signature

> **set** **defaultValue**(`value`): `void`

Gets or sets the field's default value.

##### Parameters

###### value

`string` | `number` | `boolean` | `number`[] | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`defaultValue`](Field#defaultvalue)

***

### doc

#### Get Signature

> **get** **doc**(): [`PdfDocument`](PdfDocument) \| `null`

Gets the [PdfDocument](PdfDocument) owning this field.

##### Returns

[`PdfDocument`](PdfDocument) \| `null`

#### Inherited from

[`Field`](Field).[`doc`](Field#doc)

***

### export

#### Get Signature

> **get** **export**(): `boolean`

Gets or sets a value indicating whether the field must not be exported by a [ActionSubmitForm](ActionSubmitForm) action.

##### Returns

`boolean`

#### Set Signature

> **set** **export**(`value`): `void`

Gets or sets a value indicating whether the field must not be exported by a [ActionSubmitForm](ActionSubmitForm) action.

##### Parameters

###### value

`boolean`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`export`](Field#export)

***

### formatValue

#### Get Signature

> **get** **formatValue**(): [`ActionJavaScript`](ActionJavaScript) \| `null`

Gets or sets a JavaScript action to be performed before the field is formatted to display its current value.
This action can modify the field's value before formatting.

##### Returns

[`ActionJavaScript`](ActionJavaScript) \| `null`

#### Set Signature

> **set** **formatValue**(`value`): `void`

Gets or sets a JavaScript action to be performed before the field is formatted to display its current value.
This action can modify the field's value before formatting.

##### Parameters

###### value

[`ActionJavaScriptProperties`](../type-aliases/ActionJavaScriptProperties) | [`ActionJavaScript`](ActionJavaScript) | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`formatValue`](Field#formatvalue)

***

### id

#### Get Signature

> **get** **id**(): `number`

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`Field`](Field).[`id`](Field#id)

***

### justification

#### Get Signature

> **get** **justification**(): [`VariableTextJustification`](../enumerations/VariableTextJustification) \| `null`

Gets or sets the justification to be used in displaying the field's text.
Note that this field is used only if [WidgetAnnotation#justification](WidgetAnnotation#justification) is not specified.

##### Returns

[`VariableTextJustification`](../enumerations/VariableTextJustification) \| `null`

#### Set Signature

> **set** **justification**(`value`): `void`

Gets or sets the justification to be used in displaying the field's text.
Note that this field is used only if [WidgetAnnotation#justification](WidgetAnnotation#justification) is not specified.

##### Parameters

###### value

[`VariableTextJustification`](../enumerations/VariableTextJustification) | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`justification`](Field#justification)

***

### keyPress

#### Get Signature

> **get** **keyPress**(): [`ActionJavaScript`](ActionJavaScript) \| `null`

Gets or sets a JavaScript action to be performed when the user types a keystroke into a
text field or combo box or modifies the selection in a scrollable list box.
This action can check the keystroke for validity and reject or modify it.

##### Returns

[`ActionJavaScript`](ActionJavaScript) \| `null`

#### Set Signature

> **set** **keyPress**(`value`): `void`

Gets or sets a JavaScript action to be performed when the user types a keystroke into a
text field or combo box or modifies the selection in a scrollable list box.
This action can check the keystroke for validity and reject or modify it.

##### Parameters

###### value

[`ActionJavaScriptProperties`](../type-aliases/ActionJavaScriptProperties) | [`ActionJavaScript`](ActionJavaScript) | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`keyPress`](Field#keypress)

***

### mappingName

#### Get Signature

> **get** **mappingName**(): `string` \| `null`

Gets or sets the mapping name to be used when exporting interactive form field data from the document.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **mappingName**(`value`): `void`

Gets or sets the mapping name to be used when exporting interactive form field data from the document.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`mappingName`](Field#mappingname)

***

### maxLen

#### Get Signature

> **get** **maxLen**(): `number`

Gets or sets the maximum length of the field's text, in characters.

##### Returns

`number`

#### Set Signature

> **set** **maxLen**(`value`): `void`

Gets or sets the maximum length of the field's text, in characters.

##### Parameters

###### value

`number`

##### Returns

`void`

***

### multiline

#### Get Signature

> **get** **multiline**(): `boolean`

Gets or sets a value indicating whether the field can contain multiple lines of text.

##### Returns

`boolean`

#### Set Signature

> **set** **multiline**(`value`): `void`

Gets or sets a value indicating whether the field can contain multiple lines of text.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### name

#### Get Signature

> **get** **name**(): `string` \| `null`

Gets or sets the field's name.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **name**(`value`): `void`

Gets or sets the field's name.

##### Parameters

###### value

`string`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`name`](Field#name)

***

### om

#### Get Signature

> **get** **om**(): [`ObjectManager`](ObjectManager)

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`Field`](Field).[`om`](Field#om)

***

### owner

#### Get Signature

> **get** **owner**(): [`FieldCollection`](FieldCollection) \| `null`

Gets the [FieldCollection](FieldCollection) containing this field.

##### Returns

[`FieldCollection`](FieldCollection) \| `null`

#### Inherited from

[`Field`](Field).[`owner`](Field#owner)

***

### page

#### Get Signature

> **get** **page**(): [`PdfPage`](PdfPage) \| `null`

Gets or sets the [PdfPage](PdfPage) containing this field.
This property wraps the [WidgetAnnotation#page](WidgetAnnotation#page) property
and functions identically to:
this.widget.page = value;

Note that a field may have multiple associated annotations across different pages.
These can be added and configured using the [@widgets](Field) property.

##### See

[WidgetAnnotation#page](WidgetAnnotation#page)

##### Returns

[`PdfPage`](PdfPage) \| `null`

#### Set Signature

> **set** **page**(`value`): `void`

Gets or sets the [PdfPage](PdfPage) containing this field.
This property wraps the [WidgetAnnotation#page](WidgetAnnotation#page) property
and functions identically to:
this.widget.page = value;

Note that a field may have multiple associated annotations across different pages.
These can be added and configured using the [@widgets](Field) property.

##### See

[WidgetAnnotation#page](WidgetAnnotation#page)

##### Parameters

###### value

[`PdfPage`](PdfPage) | `null`

##### Returns

`void`

***

### parent

#### Get Signature

> **get** **parent**(): [`Field`](Field) \| `null`

Gets the parent field.

##### Returns

[`Field`](Field) \| `null`

#### Inherited from

[`Field`](Field).[`parent`](Field#parent)

***

### password

#### Get Signature

> **get** **password**(): `boolean`

Gets or sets a value indicating whether the field is intended for entering a secure password that
should not be echoed visibly to the screen.

##### Returns

`boolean`

#### Set Signature

> **set** **password**(`value`): `void`

Gets or sets a value indicating whether the field is intended for entering a secure password that
should not be echoed visibly to the screen.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### readOnly

#### Get Signature

> **get** **readOnly**(): `boolean`

Gets or sets a value indicating whether the user may not change the value of the field.
Any associated widget annotations will not interact with the user; that is,
they will not respond to mouse clicks or change their appearance in response to mouse motions.
This flag is useful for fields whose values are computed or imported from a database.

##### Returns

`boolean`

#### Set Signature

> **set** **readOnly**(`value`): `void`

Gets or sets a value indicating whether the user may not change the value of the field.
Any associated widget annotations will not interact with the user; that is,
they will not respond to mouse clicks or change their appearance in response to mouse motions.
This flag is useful for fields whose values are computed or imported from a database.

##### Parameters

###### value

`boolean`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`readOnly`](Field#readonly)

***

### recalculateValue

#### Get Signature

> **get** **recalculateValue**(): [`ActionJavaScript`](ActionJavaScript) \| `null`

Gets or sets a JavaScript action to be performed to recalculate the value of this field when
that of another field changes.

##### Returns

[`ActionJavaScript`](ActionJavaScript) \| `null`

#### Set Signature

> **set** **recalculateValue**(`value`): `void`

Gets or sets a JavaScript action to be performed to recalculate the value of this field when
that of another field changes.

##### Parameters

###### value

[`ActionJavaScriptProperties`](../type-aliases/ActionJavaScriptProperties) | [`ActionJavaScript`](ActionJavaScript) | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`recalculateValue`](Field#recalculatevalue)

***

### rect

#### Get Signature

> **get** **rect**(): [`Rect`](../type-aliases/Rect)

Gets or sets the rectangle that defines the location and size of the field on a page.
This property wraps the [WidgetAnnotation#rect](WidgetAnnotation#rect) property
and functions identically to:
this.widget.rect = value;

Note that a field may have multiple associated annotations across different pages.
These can be added and configured using the [@widgets](Field) property.

##### See

[WidgetAnnotation#rect](WidgetAnnotation#rect)

##### Returns

[`Rect`](../type-aliases/Rect)

#### Set Signature

> **set** **rect**(`value`): `void`

Gets or sets the rectangle that defines the location and size of the field on a page.
This property wraps the [WidgetAnnotation#rect](WidgetAnnotation#rect) property
and functions identically to:
this.widget.rect = value;

Note that a field may have multiple associated annotations across different pages.
These can be added and configured using the [@widgets](Field) property.

##### See

[WidgetAnnotation#rect](WidgetAnnotation#rect)

##### Parameters

###### value

[`Rect`](../type-aliases/Rect)

##### Returns

`void`

***

### required

#### Get Signature

> **get** **required**(): `boolean`

Gets or sets a value indicating whether the field must have a value at the time it is
exported by a [ActionSubmitForm](ActionSubmitForm) action.

##### Returns

`boolean`

#### Set Signature

> **set** **required**(`value`): `void`

Gets or sets a value indicating whether the field must have a value at the time it is
exported by a [ActionSubmitForm](ActionSubmitForm) action.

##### Parameters

###### value

`boolean`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`required`](Field#required)

***

### richText

#### Get Signature

> **get** **richText**(): `boolean`

Gets or sets a value indicating whether the value of this field should be represented as a rich text string.

##### Returns

`boolean`

#### Set Signature

> **set** **richText**(`value`): `void`

Gets or sets a value indicating whether the value of this field should be represented as a rich text string.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### richTextValue

#### Get Signature

> **get** **richTextValue**(): `string` \| `null`

Gets or sets the rich text to be displayed in the TextField.
This text can be formatted using HTML tags, see PDF specification for details.
Note that DsPdfJS does not automatically regenerates appearance streams for text fields containing RTF text.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **richTextValue**(`value`): `void`

Gets or sets the rich text to be displayed in the TextField.
This text can be formatted using HTML tags, see PDF specification for details.
Note that DsPdfJS does not automatically regenerates appearance streams for text fields containing RTF text.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

***

### scrollable

#### Get Signature

> **get** **scrollable**(): `boolean`

Gets or sets a value indicating whether the field is scrollable to accommodate more text than
fits within its annotation rectangle.

##### Returns

`boolean`

#### Set Signature

> **set** **scrollable**(`value`): `void`

Gets or sets a value indicating whether the field is scrollable to accommodate more text than
fits within its annotation rectangle.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### spellCheck

#### Get Signature

> **get** **spellCheck**(): `boolean`

Gets or sets a value indicating whether the text entered in the field is spell-checked.

##### Returns

`boolean`

#### Set Signature

> **set** **spellCheck**(`value`): `void`

Gets or sets a value indicating whether the text entered in the field is spell-checked.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### text

#### Get Signature

> **get** **text**(): `string` \| `null`

Gets or sets the text of TextField.

##### Returns

`string` \| `null`

#### Set Signature

> **set** **text**(`value`): `void`

Gets or sets the text of TextField.

##### Parameters

###### value

`string` | `null`

##### Returns

`void`

***

### value

#### Get Signature

> **get** **value**(): `string` \| `number` \| `boolean` \| `number`[] \| `null`

Gets or sets the field's value.

##### Returns

`string` \| `number` \| `boolean` \| `number`[] \| `null`

#### Set Signature

> **set** **value**(`value`): `void`

Gets or sets the field's value.

##### Parameters

###### value

`string` | `number` | `boolean` | `number`[] | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`value`](Field#value)

***

### valueChanged

#### Get Signature

> **get** **valueChanged**(): [`ActionJavaScript`](ActionJavaScript) \| `null`

Gets or sets a JavaScript action to be performed when the field's value is changed.
This action can check the new value for validity.

##### Returns

[`ActionJavaScript`](ActionJavaScript) \| `null`

#### Set Signature

> **set** **valueChanged**(`value`): `void`

Gets or sets a JavaScript action to be performed when the field's value is changed.
This action can check the new value for validity.

##### Parameters

###### value

[`ActionJavaScriptProperties`](../type-aliases/ActionJavaScriptProperties) | [`ActionJavaScript`](ActionJavaScript) | `null`

##### Returns

`void`

#### Inherited from

[`Field`](Field).[`valueChanged`](Field#valuechanged)

***

### widget

#### Get Signature

> **get** **widget**(): [`WidgetAnnotation`](WidgetAnnotation)

Gets the [WidgetAnnotation](WidgetAnnotation) defining view properties of the text field.

##### Returns

[`WidgetAnnotation`](WidgetAnnotation)

***

### widgets

#### Get Signature

> **get** **widgets**(): [`FieldWidgetCollection`](FieldWidgetCollection)

Gets the list of widget annotations associated with this field.

##### Returns

[`FieldWidgetCollection`](FieldWidgetCollection)

#### Inherited from

[`Field`](Field).[`widgets`](Field#widgets)

## Methods

### free()

> **free**(): `void`

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`Field`](Field).[`free`](Field#free)

***

### rebind()

> **rebind**(`omTo`): `void`

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`Field`](Field).[`rebind`](Field#rebind)
