Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 489 Bytes

README.md

File metadata and controls

29 lines (21 loc) · 489 Bytes

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)
}