Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
form-serialize
Advanced tools
serialize form fields to submit a form over ajax
npm install form-serialize
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' }
Returns a serialized form of a HTMLForm element. Output is determined by the serializer used. Default serializer is url-encoded.
arg | type | desc |
---|---|---|
form | HTMLForm | must be an HTMLForm element |
options | Object | optional options object |
option | type | desc |
---|---|---|
hash | boolean | if true, the default hash serializer will be used |
serializer | function | provide a 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.
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
This module is based on ideas from jQuery serialize and the Form.serialize method from the prototype library
MIT
FAQs
serialize html forms
The npm package form-serialize receives a total of 44,832 weekly downloads. As such, form-serialize popularity was classified as popular.
We found that form-serialize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.