← Community home

Why is a field missing from submitted form data?

Community › Forums › HTML Forms › Why is a field missing from submitted form data?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #78

    A field is visible and has an id, yet the server never receives its value.

    #79

    Detailed answer

    Ordinary form submission sends name/value pairs.

    Check that the field has a name and belongs to the submitted form. Disabled fields and unchecked checkboxes are normally omitted. Inspect the actual request in developer tools to compare what the browser sends with the names expected by the server.

    Example

    <form action="/subscribe" method="post"><label for="name">Name</label><input id="name" name="full_name"><button>Subscribe</button></form>

    Understanding the behavior

    A control generally needs a name to contribute a key to submitted form data. Disabled controls are excluded, unchecked checkboxes are absent, and only the relevant submitter contributes its name and value. An id serves a different purpose.

    Practical implementation notes

    Inspect FormData for the actual form and compare its keys with the server's expected field names. Do not assume that a value visible on screen must be included in the request.

    How to check it

    Submit the form and inspect the request payload before and after adding name.

    Expected result

    The payload contains full_name when a successful named control is submitted.

    Watch out: An id alone does not make a field part of submitted name/value data.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.