🍞 Forn
Parse the form data into a plain object for either Javascript or React:
; // React version - logs "{ hello: 'world' }" if submitted like this <form onSubmit=> <input name="hello" defaultValue="world" /> <button>Send</button> </form>; // JQuery version - also logs "{ hello: 'world' }" when submitted; // Plain Javascript version - logs "{ hello: 'world' }" when submitteddocument;
To work with <input type="file">
you'll need to switch to receiving FormData
instead of a plain object. To do this, add an enctype="multipart/form-data"
to the <form>
element:
<!-- HTML form definition to use FormData --> Send
; // React form definition to use FormData. Note it's 'encType' and not 'enctype' <form encType="multipart/form-data" onSubmit=> <input name="hello" placeholder="world"> <input name="file" type="email"> <button>Send</button> </form>;