Source Code:
(back to article)
Submit
Result:
Report an issue
<script> async function onSubmit(event) { event.preventDefault(); const form = document.getElementById('myForm'); const formData = new FormData(form); let results = ''; for (const [key, value] of formData.entries()) { results += `${key}: ${value}\n`; } alert(results) } </script> <form id="myForm" onsubmit="onSubmit(event)"> <input type="text" name="username" value="John Doe"> <input type="email" name="email" value="john@example.com"> <input type="submit"> </form>