# jquery-serializefields

> [![npm version](https://badge.fury.io/js/jquery-serializefields.svg)](http://badge.fury.io/js/jquery-serializefields)

Latest version **0.1.3** (published 2022-01-19) · 0 weekly downloads

## Install

```sh
npm install jquery-serializefields
pnpm add jquery-serializefields
yarn add jquery-serializefields
bun add jquery-serializefields
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2022-01-19 |
| First published | 2015-05-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jonathan Simon Prates |
| Maintainers | jonathansp, broilogabriel, cristianoliveira |
| Keywords | serialize, serializeObject, jquery-plugin |

## Links

- npm: https://www.npmjs.com/package/jquery-serializefields
- npm.io page: https://npm.io/package/jquery-serializefields

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2022-01-19
- 0.1.2 — 2021-11-29
- 0.1.1 — 2021-11-29
- 0.1.0 — 2021-11-29
- 0.0.4 — 2015-06-09
- 0.0.3 — 2015-06-03
- 0.0.2 — 2015-05-08
- 0.0.1 — 2015-05-08

## README

# jquery-serializeFields

[![npm version](https://badge.fury.io/js/jquery-serializefields.svg)](http://badge.fury.io/js/jquery-serializefields)

jQuery plugin to serialize form elements into a json object using `<fieldset>` elements.

## How to use

Form:

```html
<form id="form1">
    <input type="text" name="username" value="my user name" />

    <fieldset name="address">
        <input type="text" name="street" value="654, test street" />
        <input type="text" name="country" value="Brazil" />
    </fieldset>

    <fieldset name="contact">
        <input type="text" name="email" value="contact@mysite.com" />
        <fieldset name="phones">
            <input type="text" name="primary" value="+55 51 123456789" />
            <input type="text" name="mobile" value="+55 51 987654987" />
        </fieldset>
    </fieldset>

    <input type="submit" />
</form>

```

Code:

```javascript
$(document).ready(() => {
    $("#form1").submit(event => {
        event.preventDefault()

        let data = $("#form1").serializeFields()
        console.log(JSON.stringify(data))
    })
})
```

Result:

```javascript
{
    "username": "my user name",
    "address": {
        "street": "654, test street",
        "country": "Brazil"
    },
    "contact": {
        "email": "contact@mysite.com",
        "phones": {
            "primary": "+55 51 123456789",
            "mobile": "+55 51 987654987"
        }
    }
}
```

Options:

```javascript
let data = $("#myform").serializeFields({
    fieldset_nameattr: "name",
    field_selector: "input:enabled,select:enabled,textarea:enabled",
    ignored_fields: "input[type='radio']:not(:checked)"
})
```

## Build

```bash
npm install

npm install -g grunt-cli

grunt build
```
The minified output file will be placed to ./dist folder.

## Release

* 0.1.3 Fix for shelljs vulnerability.
* 0.1.2 Remove bower.
* 0.1.1 Add textarea as then default selector.
* 0.1.0 Updated npm.
* 0.0.5 Updated old dependencies.
* 0.0.4 Added support to radio and select inputs.
* 0.0.3 Added support to ignore fields and checkbox fix.
* 0.0.2 Added support to nested elements.
* 0.0.1 First version.

### NPM

See https://www.npmjs.com/package/jquery-serializefields

```bash
npm install jquery-serializefields
```

Licensed under GPL license.

---
_Source: https://npm.io/package/jquery-serializefields · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
