frappacchio / form-serialize

Repository from Github https://github.comfrappacchio/form-serializeRepository from Github https://github.comfrappacchio/form-serialize

Index

Installation

yarn

yarn add form-serialize-all

npm

npm install --save form-serialize-all

Usage

<form action="" class="example-form">
  <input type="text" value="My awesome name" name="name" />
  <input type="text" value="My awesome surname" name="surname" />
  <input type="checkbox" value="I am the most modest person in the world" name="modest" checked="" />
</form>
import SerializeForm from 'form-serialize-all';

const myFormElement = document.querySelector('.example-form');
const seralize = new SerializeForm(myFormElement);

console.log(seralize.getData('array')); // [{name:'My awesome name'}, {surname:'My awesome surname'}, {modest:'I am the most modest person in the world'}]
console.log(seralize.getData('object')); //{name:'My awesome name', surname:'My awesome surname', modest:'I am the most modest person in the world'}
console.log(seralize.getData()); // 'name=My awesome name&surname=My awesome surname&modest=I am the most modest person in the world'

License

Apache License

About

License:Apache License 2.0


Languages

Language:JavaScript 90.6%Language:HTML 9.4%