form-2-json

1.0.5 • Public • Published

yarn add form-2-json

input fields inside the form, must have name attribute, like -

<input name='age' />

import { form2json } from 'form-2-json'
form2json(event.target)

this function will return a json

Example

document.querySelecor('form').addEventListener('submit', handleSubmit)
function handleSubmit (e) {
  e.preventDefault()
  let myjson = form2json(e.target)
  console.log(myjson)
}

Readme

Keywords

Package Sidebar

Install

npm i form-2-json

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

3.38 kB

Total Files

8

Last publish

Collaborators

  • srsajjad