Skip to content

Instantly share code, notes, and snippets.

@yeungon
Forked from everdimension/collect_form_data.js
Created June 5, 2019 03:44
Show Gist options
  • Save yeungon/2a4554620c1e4030aa393b71c540cdd1 to your computer and use it in GitHub Desktop.
Save yeungon/2a4554620c1e4030aa393b71c540cdd1 to your computer and use it in GitHub Desktop.
A way to collect form data without `FormData` api.
handleSubmit(event) {
const form = event.target;
const data = {}
for (let element of form.elements) {
if (element.tagName === 'BUTTON') { continue; }
data[element.name] = element.value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment