Serialize form

JavaScript, Browser, String · Oct 22, 2020

Encodes a set of form elements as a query string.

const serializeForm = form =>
  Array.from(new FormData(form), field =>
    field.map(encodeURIComponent).join('=')
  ).join('&');
serializeForm(document.querySelector('#form'));
// email=test%40email.com&name=Test%20Name

More like this

  • Form to object

    JavaScript, Browser

    Encodes a set of form elements as an object.

  • Serialize cookie

    JavaScript, Browser

    Serializes a cookie name-value pair into a Set-Cookie header string.

  • Vertical offset of element

    JavaScript, Browser

    Finds the distance from a given element to the top of the document.