better-onsubmit
v2.0.1
Published
💾 Get an HTML form values as a JS object
Downloads
4
Maintainers
Readme
💾 Better-OnSubmit
Usage
<script src="https://cdn.jsdelivr.net/gh/mvoloskov/better-onsubmit/betterOnsubmit.min.js"></script>
<script>
document.getElementById('myAmazingForm').onsubmit = betterOnsubmit(values => {
// do whatever you want with the values
console.log(values)
})
</script>
Thanks to Cosmopolite Formie is also available as a NPM package:
npm install better-onsubmit
import betterOnsubmit from 'better-onsubmit'
const onSubmit = betterOnsubmit(values => {
console.log(values)
})
document.getElementById('myAmazingForm').onsubmit = onSubmit
JSON example
You'll get a JSON like this from your submitted form:
{
about: "",
country: "usa",
date: "1930-08-05",
email: "[email protected]",
"eyes-color": "#000000",
gender: "male",
name: "Neil Alden Armstrong",
password: "",
phone: "",
photo: FileList {length: 0},
"has-speedy": true,
}