form-2-json
v1.0.5
Published
a small module to transform form inputs into json
Downloads
3
Readme
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)
}