# Javascript: ApplicationFieldCollection.remove Method

> Removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: ApplicationFieldCollection.remove Method
- **565 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfieldcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfieldcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/applicationfieldcollection/remove-method/llms-full.txt

---

### Description

Removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

### Syntax

```javascript
<void> ApplicationFieldCollection.remove(<ApplicationField> applicationField, <Boolean> keepText, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| applicationField | Specifies the field to remove. |
| keepText | If this parameter is set to true, the field is removed without deleting its visible text. Otherwise, the field's text is also deleted. |
| callback | Optional. Receives true, if the field could be removed. Otherwise, it is false. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `ApplicationFieldCollection.remove` in a practical document-editing workflow. It removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

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

function remove(applicationField) {
    TXTextControl.textParts.getMainText(function(mainText) {
        const applicationFields = mainText.applicationFields;
        applicationFields.remove(
            applicationField,
            true,
            function(result) {
                if (result) {
                    console.log("remove is available.");
                } else {
                    console.warn("remove is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}
```

---

## Nearby

- **Previous:** [Javascript: ApplicationFieldCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/applicationfieldcollection/getitem-method/llms-full.txt)
- **Next:** [Barcode Object](https://docs.textcontrol.com/ds-server/reference/javascript/barcode/llms-full.txt)
