Thanks to visit codestin.com
Credit goes to github.com

Skip to content

textpain/better-onsubmit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💾 Better-OnSubmit

Dependencies npm My github My twitter

Demo   •   Usage

Get values from HTML form as JSON.

Usage

<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 = 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,
}

About

💾 Get an HTML form values as a JS object

Resources

License

Stars

Watchers

Forks

Sponsor this project