The key difference in disabled vs readonly is what happens beyond editing. A disabled native input is excluded from ordinary form submission and sequential keyboard focus. A supported read-only input stays focusable and can contribute its named value. If a field looks filled in but disappears from your request, check its effective disabled state before changing your backend.
This guide is for developers launching public forms, student project editors, and registration pages. It shows how to choose the state, diagnose missing entries, and test a small form without sending data to a server.
Choose disabled vs readonly by the field's job
Use disabled when a supported native control is unavailable for interaction and its value should not participate in ordinary form submission. Use readonly for supported text-like inputs or a textarea whose value should remain available for review, focus, and submission while user editing is prevented.
For example, a project reference that a visitor may copy can be a read-only text input. An unavailable optional field may be disabled, with a visible explanation of what enables it. If the visitor only needs to read information, ordinary text may be clearer than an input.
MDN documents disabled control behavior and the controls that support readonly. Check support before adding the attribute: readonly does not make a select, checkbox, radio button, or file input read-only. For those controls, design the intended interaction or show a summary rather than adding an ineffective attribute.
Both attributes are Boolean HTML attributes. Writing disabled="false" still declares a disabled state. Remove the attribute or set the DOM property to false to enable the control. In JSX, pass a Boolean expression to disabled; inspect the rendered DOM when a wrapper component appears to ignore it.
Neither state is a server authorization rule. A visitor can change HTML or send a request independently of the form. The server must validate incoming data and determine which records and fields the user may change.
Find why a disabled input is not submitted
Start with the rendered form and the actual outgoing request. For ordinary browser form submission and new FormData(form), disabled controls are omitted. Custom code that reads .value and builds JSON can behave differently. Trace the code path your application actually uses.
In DevTools, select the affected native input and inspect:
({
name: $0.name,
value: $0.value,
ownDisabled: $0.disabled,
effectiveDisabled: $0.matches(":disabled"),
readOnly: $0.readOnly,
formId: $0.form?.id,
})
The disabled property reports the input's own attribute. :disabled also matches an input disabled through a containing fieldset. A field can therefore have ownDisabled: false and effectiveDisabled: true. Check its ancestors before changing the input component.
Then inspect the entries produced from its form:
Array.from(new FormData($0.form).entries())
Use this only when the selected input has an associated form, and avoid displaying real sensitive data in shared logs or screenshots. The FormData constructor reference explains how existing form controls supply entries. Constructing FormData does not itself submit a request or run native validation.
If the field is enabled but still missing, check its name, form association, and control-specific rules. An id connects labels and references; it does not replace a submission name. Unchecked checkboxes are also omitted. The HTML entry-list algorithm defines these rules. For repeated names, inspect all entries or use getAll(); converting to a plain object can hide repeated values.
Reproduce the difference with a local form
Save this as field-state-demo.html and serve it locally. The reference remains reviewable, the unavailable field is omitted, and the project title stays editable. The button prints a local payload preview without submitting anything.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Form field state demo</title>
<style>
body { font: 1rem/1.5 system-ui; margin: 1rem; }
label, input { display: block; }
input { box-sizing: border-box; max-width: 100%; margin-bottom: 1rem; }
:focus-visible { outline: 3px solid #2457c5; outline-offset: 3px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
</style>
</head>
<body>
<main>
<h1>Review a project</h1>
<form id="project-form">
<label for="reference">Project reference</label>
<input id="reference" name="reference" value="DEMO-104" readonly>
<label for="archive">Archive note (unavailable for this project)</label>
<input id="archive" name="archive" value="Not archived" disabled>
<label for="title">Project title</label>
<input id="title" name="title" value="Launch notes">
<button id="preview" type="button">Preview form data</button>
</form>
<h2>Local payload preview</h2>
<pre id="payload"></pre>
</main>
<script>
const form = document.querySelector("#project-form");
document.querySelector("#preview").addEventListener("click", () => {
const entries = Array.from(new FormData(form).entries());
document.querySelector("#payload").textContent =
JSON.stringify(entries, null, 2);
});
</script>
</body>
</html>
Click Preview form data. Expect two entries: reference and title. The disabled archive note remains visible but is absent from the preview. Change the project title and preview again; the new value should appear. The preview uses an array so repeated names would remain visible.
Tab from the browser's page entry point: the reference should receive focus, the archive field should be skipped, and the editable title and Preview button should follow. Check that the reference can be selected and copied in your supported browsers. Use the keyboard accessibility testing guide for a fuller manual pass, including visible focus and reverse navigation.
Check inherited states and validation
A disabled fieldset disables its descendant form controls, except controls within its first legend child. This is useful for a deliberately unavailable section, but can unexpectedly remove several values from a request. The HTML fieldset reference describes the inheritance and legend exception. Inspect the whole group when multiple fields vanish together.
Disabled controls and supported read-only inputs do not participate in native constraint validation. Do not put required on those fields and expect the browser to demand a value. In a conditional form, enable the relevant section before asking the visitor to complete it, then test both the available and unavailable paths.
When custom validation fails, preserve the visitor's editable answers and explain the correction. The accessible form errors guide covers field descriptions, error summaries, and recovery. A grey field without an explanation leaves the visitor guessing whether it is unavailable, still loading, or broken.
aria-disabled="true" is a different contract. It communicates an unavailable state without implementing native disabling, removing focus, or excluding a field from FormData. Developers must suppress activation themselves when choosing this approach, as the ARIA disabled reference explains. Prefer native disabling where that behavior fits; do not add ARIA solely to change a field's appearance.
Capture form data before disabling a pending form
A common missing-values bug starts in a submit handler: code disables a fieldset to prevent further interaction, then constructs FormData. Its formerly enabled fields are now excluded.
When handling a valid submit event, the relevant ordering is:
const payload = new FormData(form, event.submitter);
fieldset.disabled = true;
Capture the intended entries while the controls are enabled. Then enter the pending state and send that captured payload. Restore the controls in a finally path after the operation finishes, and show success only after the server confirms the intended result. This ordering fragment assumes form, fieldset, and the submit event already exist; it is not a complete request handler.
Prevent duplicate in-flight operations at the handler as well as in the interface. If you disable only the submit button, capture its name/value before disabling it when that submitter value matters. The HTML button type guide explains submitter selection and Enter-key behavior. Test your framework's serialization path rather than assuming it follows native FormData rules.
Add disabled vs readonly regression tests
In an existing Playwright project, set FIELD_STATE_DEMO_URL to the local demo's full URL and save this test. It verifies the payload and keyboard behavior, including that typing cannot change the reference.
import { expect, test } from "@playwright/test";
for (const width of [375, 1280]) {
test(`field states at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await page.goto(process.env.FIELD_STATE_DEMO_URL!);
const reference = page.getByLabel("Project reference", { exact: true });
const archive = page.getByLabel("Archive note", { exact: false });
const title = page.getByLabel("Project title", { exact: true });
const preview = page.getByRole("button", { name: "Preview form data" });
await expect(reference).not.toBeEditable();
await expect(archive).toBeDisabled();
await reference.focus();
await reference.press("End");
await page.keyboard.type("changed");
await expect(reference).toHaveValue("DEMO-104");
await page.keyboard.press("Tab");
await expect(title).toBeFocused();
await title.fill("Release notes");
await page.keyboard.press("Tab");
await expect(preview).toBeFocused();
await page.keyboard.press("Space");
await expect(page.locator("#payload")).toHaveText(JSON.stringify([
["reference", "DEMO-104"],
["title", "Release notes"],
], null, 2));
});
}
Playwright's retrying locator assertions check the expected state while the page settles. Run the test in your supported browsers. These two widths do not establish screen-reader usability or prove a backend stored the right values. For a real submission, add a controlled endpoint test that checks the actual request, pending state, failure recovery, and persisted result using the website form testing checklist.
Audit the deployed form's surrounding interface
Once the field-state tests pass, run Slop Audit on the public form page. Review the available form-label findings, axe violation evidence, sampled Tab focus, mobile overflow, and screenshots. Use those observations to fix the surrounding interface, then rescan the deployed route.
Slop Audit's bounded first-task evaluator excludes form-associated buttons from activation. It does not submit the form, compare disabled and read-only payloads, or verify server authorization and persistence. Keep the focused browser test and your request-level evidence beside the audit report so the release review covers both behavior and the public page.