---
name: "up.form.fields"
area: "API"
kind: "JavaScript function"
parent: "up.form module"
url: "https://unpoly.com/api/up.form.fields"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.form module](https://unpoly.com/api/up.form.md)</nav>

# up.form.fields(root)

Returns a list of form fields within the given element.

You can configure what Unpoly considers a form field by adding CSS selectors to the [`up.form.config.fieldSelectors`](https://unpoly.com/api/up.form.config.md#config.fieldSelectors) array.

If the given element is itself a form field, a list of that given element is returned.

If the given element is a `<form>` with an `[id]`, the list also includes fields outside the form that are associated with it through a [`[form]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form) attribute.

Fields in another [layer](https://unpoly.com/api/up.layer.md) and fields that are being [destroyed](https://unpoly.com/api/up.destroy.md) are ignored.

---

## Parameters {#parameters}

### root {#root}

(required)

The element to scan for contained form fields.

If the element is itself a form field, a list of that element is returned.

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) | [jQuery](https://learn.jquery.com/using-jquery-core/jquery-object/)

---

## Return value {#return-value}

The field elements within the given element.

Type: [List](https://unpoly.com/api/List.md)<[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)>

