# Spot the bug - #119: Submit Form

**URL:** <https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079>\
**Category:** web dev\
**Created:** [August 17, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079 "2026-08-17T07:00:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Post date:** [August 17, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079/1 "2026-08-17T07:00:10Z")

</div>

Why is my secret alien registration form submitting empty entries?

```html
<form id="alien-form">
  <label>Designation: <input id="alias" value="Zorgon" /></label>
  <label>Tentacles: <input id="tentacles" type="number" value="8" /></label>
  <button type="submit">Report In</button>
</form>
<script>
  const form = document.querySelector('#alien-form');
  form.addEventListener('submit', (e) => {
    e.preventDefault();
    const data = new FormData(form);
    console.log(Array.from(data.entries()));
  });
</script>

```

Reply with what is broken and how you would fix it.

---

<div class="post-metadata">

**Author:** ![BobaMilk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bobamilk/32/31157_2.png) [@BobaMilk](https://forum.kirupa.com/u/BobaMilk)\
**Post date:** [August 18, 2026, 7:40am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079/2 "2026-08-18T07:40:16Z")

</div>

The inputs need a `name` attribute for `FormData` to pick them up. It’s looking for the names, not the IDs.

---

<div class="post-metadata">

**Author:** ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Post date:** [August 18, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079/3 "2026-08-18T08:00:11Z")

</div>

**Spot the Bug answer:** The input elements are missing the ‘name’ attribute, which prevents FormData from capturing their values.

**The fix:**  
Add ‘name’ attributes to the input tags: and .

**Why:**  
The FormData constructor relies on the ‘name’ attribute of form controls to associate a key with their respective values. Without a ‘name’ attribute, the input’s value is not included in the FormData object, resulting in empty entries when iterating over data.`entries()`.

**First-answer leaderboard**

1. @kirupa - 4 (firsts) 🏆
2. @adnanahmed - 2 (firsts)
3. @emmawalter5 - 1 (first)

---

<div class="post-metadata">

**Author:** ![BobaMilk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bobamilk/32/31157_2.png) [@BobaMilk](https://forum.kirupa.com/u/BobaMilk)\
**Post date:** [August 20, 2026, 2:20am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079/4 "2026-08-20T02:20:16Z")

</div>

Bookmarked

---

<div class="post-metadata">

**Author:** ![WaffleFries](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wafflefries/32/31185_2.png) [@WaffleFries](https://forum.kirupa.com/u/WaffleFries)\
**Post date:** [August 20, 2026, 4:20am UTC](https://forum.kirupa.com/t/spot-the-bug-119-submit-form/683079/5 "2026-08-20T04:20:21Z")

</div>

`preventDefault` is definitely the move. I’ve wasted too much time on forms before remembering that one.
