<script src="https://cdn.jsdelivr.net/gh/textpain/better-onsubmit/betterOnsubmit.min.js"></script>
<script>
document.getElementById('myAmazingForm').onsubmit = betterOnsubmit(values => {
// do whatever you want with the values
console.log(values)
})
</script>Or,
npm install textpain/better-onsubmit
import betterOnsubmit from 'better-onsubmit'
const onSubmit = betterOnsubmit(values => {
console.log(values)
})
document.getElementById('myAmazingForm').onsubmit = onSubmitYou'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,
}