Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

form-serialize

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-serialize

serialize html forms

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54K
increased by15.95%
Maintainers
1
Weekly downloads
 
Created
Source

form-serialize

badge

serialize form fields to submit a form over ajax

install

npm install form-serialize

use

form-serialize supports two output formats, url encoded (default) or hash (js objects).

Lets serialize the following html form:

<form id="example-form">
	<input type="text" name="foo" value="bar"/>
	<input type="submit" value="do it!"/>
</form>
var serialize = require('form-serialize');
var form = document.querySelector('#example-form');

var str = serialize(form);
// str -> "foo=bar"

var obj = serialiez(form, { hash: true });
// obj -> { foo: 'bar' }

api

serialize(form [, options])

Returns a serialized form of a HTMLForm element. Output is determined by the serializer used. Default serializer is url-encoded.

argtypedesc
formHTMLFormmust be an HTMLForm element
optionsObjectoptional options object
options
optiontypedesc
hashbooleanif true, the default hash serializer will be used
serializerfunctionprovide a custom serializer

custom serializer

Serializers take 3 arguments: result, key, value and should return a newly updated result.

See the example serializers in the index.js source file.

notes

only successfull control form fields are serialized

multiselect fields with more than one value will result in an array of values in the hash output mode using the default hash serializer

references

This module is based on ideas from jQuery serialize and the Form.serialize method from the prototype library

license

MIT

Keywords

FAQs

Package last updated on 13 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc