Content · Web Development · HTML

HTML Avoiding Disabled Fields When Their Values Are Needed

Avoiding Disabled Fields When Their Values Are Needed: The disabled field is not submitted, while the readonly named field is submitted. Includes a practical HTML example and an explanation.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A form should feel easy to use. The visitor sees a question, gives an answer, and needs to know what will happen next.

What You Need to Know


The disabled field is not submitted, while the readonly named field is submitted.

Try the Example


Take a look at the example. We’ll explain the important lines right below it.

<form action="/reservation" method="post">
    <label for="display-room">Assigned room (display only)</label>
    <input id="display-room" value="Room 12" disabled>
    <label for="booking-code">Booking code (included in submission)</label>
    <input id="booking-code" name="booking-code" value="B-321" readonly>
    <button type="submit">Confirm booking</button>
</form>

Let’s Read the Code


  • value: The value is the actual data associated with a control or choice.
  • <form>: The form groups controls and identifies where submitted data goes.
  • <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
  • for: For connects a label or output with a control by ID.

Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.

What Happens in the Browser?


The HTML controls work in the browser, but saving an answer requires the example action path to be handled by a real server.

Compare field states. A disabled control is normally omitted from submission. A supported readonly control can still be submitted, while an inert region prevents ordinary interaction. These attributes solve different problems, so choose them for their behavior rather than their appearance.

Your Turn


Open the Network panel, submit the form, and compare what arrives before and after adding disabled. Which values disappear?

Common Beginner Mistakes


  • Expecting a disabled form field to be included in the submitted values.
  • Readonly is not a security boundary. A server must verify that the booking code is genuine.

Key Takeaways


  • Choose the HTML feature that explains this task clearly.
  • value: The value is the actual data associated with a control or choice.
  • Remember that HTML form rules help the visitor, but server-side code must decide whether received data is valid.
Share this resourceSend this page to someone who may find it useful.