1.0.0 • Published 7 years ago

formdata-to-object v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

formdata-to-object stability

npm version build status downloads js-standard-style

Convert a formData object or form DOM node to a KV object.

Generally you don't want to use this method, but attach a onchange listener to each input element instead. Useful in certain situations tho.

Usage

var toObject = require('formdata-to-object')
var html = require('bel')

document.body.appendChild(html`
  <form>
    <input type="text" name="name">
    <input type="password" name="password">
    <input type="submit" value="Login">
  </form>
`)

var form = document.querySelector('form')
var data = toObject(form)
console.log(data)

API

data = toObject(FormData|formElement)

Convert a window.FormData object or form element to an object.

License

MIT

1.0.0

7 years ago