add test, update tags, update description
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
### formToObject
|
||||
|
||||
Serializes a form into an object.
|
||||
Encode a set of form elements as a `object`.
|
||||
|
||||
First we transform the `form` into `FormData`, then we convert it into an `array` and from the `array` we collect an `object`
|
||||
|
||||
@ -13,13 +13,6 @@ const formToObject = form =>
|
||||
}), {})
|
||||
```
|
||||
|
||||
```html
|
||||
<form id="form">
|
||||
<input name="email" type="email" />
|
||||
<input name="name" />
|
||||
</form>
|
||||
```
|
||||
|
||||
```js
|
||||
formToObject(document.querySelector('#form')) // { email: 'test@email.com', name: 'Test Name' }
|
||||
```
|
||||
@ -1,6 +1,6 @@
|
||||
### serializeForm
|
||||
|
||||
Serializes a form into an object.
|
||||
Encode a set of form elements as a query string.
|
||||
|
||||
First we transform the `form` into `FormData`, then we convert it into an `array` and from the `array` we collect an `query string`
|
||||
|
||||
@ -9,13 +9,6 @@ const serializeForm = form =>
|
||||
Array.from(new FormData(form), field => field.map(encodeURIComponent).join('=')).join('&')
|
||||
```
|
||||
|
||||
```html
|
||||
<form id="form">
|
||||
<input name="email" type="email" />
|
||||
<input name="name" />
|
||||
</form>
|
||||
```
|
||||
|
||||
```js
|
||||
serializeForm(document.querySelector('#form')) // email=test%40email.com&name=Test%20Name
|
||||
```
|
||||
Reference in New Issue
Block a user