# TextFieldCollection Object

> Contains all standard text fields in a Text Control document or part of the document.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > TextFieldCollection Object
- **732 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/llms-full.txt

---

### Description

Contains all standard [text fields](https://docs.textcontrol.com/ds-server/reference/javascript/textfield/llms-full.txt) in a Text Control document or part of the document.

### Syntax

```javascript
TextFieldCollection
```

### Examples

The following example demonstrates `TextFieldCollection` in a practical document-editing workflow. It contains all standard text fields in a Text Control document or part of the document.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const textFields = mainText.textFields;
    textFields.getItem(
        function(field) {
            if (!field) {
                console.warn("No text field was returned.");
                return;
            }
            
            console.log("get item result:", field);
        },
        onTxError,
        25
    );
}, onTxError);
```

---

## In This Section

- [Javascript: TextFieldCollection.add Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/add-method/llms-full.txt): Adds a new TextField to the collection.
- [Javascript: TextFieldCollection.addWithText Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/addwithtext-method/llms-full.txt): Adds a new TextField with the given text to the collection.
- [Javascript: TextFieldCollection.clear Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/clear-method/llms-full.txt): Removes all text fields from a Text Control document.
- [Javascript: TextFieldCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/getitem-method/llms-full.txt): Gets the text field at the current text input position or the text field with the specified id.
- [Javascript: TextFieldCollection.remove Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/remove-method/llms-full.txt): Removes the text field from the Text Control document.

---

## Nearby

- **Previous:** [TextFieldCallback Function](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcallback/llms-full.txt)
- **Next:** [Javascript: TextFieldCollection.add Method](https://docs.textcontrol.com/ds-server/reference/javascript/textfieldcollection/add-method/llms-full.txt)
