Key Takeaways
A named, enabled text input can remain in FormData when it is readonly. A disabled input is omitted, and an unnamed input contributes no corresponding key. Compare the serialized keys and values before changing the UI. Neither readonly nor disabled replaces server checks of identity, authorization or allowed values.
- Visibility, editability and inclusion in serialized data are separate conditions.Read the supporting section: Check whether the key exists at all
- The sample includes batch and quantity, but omits disabled sku and the unnamed input.Read the supporting section: Four visible inputs produce two initial keys
- Readonly text can still be submitted; it does not make the submitted value trustworthy.Read the supporting section: Choose a repair that matches the field contract
In this article
Check whether the key exists at all
The FormData constructor documentation describes collecting eligible form controls through their names and current values. This example has no formdata listeners or custom JSON builder. If a real application changes the data afterward, inspect that separate transformation too.
An absent key differs from a present key containing an empty string. Record the actual keys rather than assuming the server erased A-17. A numeric validity error belongs to a different check: see min, step and numeric input validity.
Four visible inputs produce two initial keys
This is an authored HTML sample. On December 2, 2026, the editor executed it in an isolated Edge 158.0.4370.45 page and inspected local FormData. No form request was sent and no real product record was read. Every input uses the default text type.
<form id="sample">
<input name="sku" value="A-17" disabled>
<input name="batch" value="B-02" readonly>
<input name="quantity" value="3">
<input value="note">
</form>
<script>
const form = document.querySelector("#sample");
console.log([...new FormData(form)]);
// [["batch", "B-02"], ["quantity", "3"]]
</script>| Input | State | Initial FormData |
|---|---|---|
| sku=A-17 | disabled; named | No sku key |
| batch=B-02 | readonly; named | batch=B-02 |
| quantity=3 | enabled; named | quantity=3 |
| note | No name | No corresponding key |
Choose a repair that matches the field contract
If sku must be transmitted but should not be edited in the UI, consider readonly on a supported text input and retain its name. If it is genuinely inapplicable, keep it disabled and define how the server obtains the value from trusted context. Do not enable every control merely to make the payload look complete.
In the same isolated check, setting sku.disabled to false added sku=A-17 to a new FormData object. Changing the readonly batch value through script to B-03 also changed the serialized value. Readonly constrains ordinary user editing; it does not authenticate a request value.
The readonly reference excludes select, checkboxes and file inputs. Adding readonly to an arbitrary control does not give it the text-input behavior. Disabled controls also affect focus and interaction. After a change, use the keyboard path and focus checks where appropriate.
Verify each boundary separately
In an authorized test environment, inspect the current control attributes, constructed key/value list, outgoing payload, server input and saved record in that order. This browser sample verifies only the first two; it does not establish successful saving in a business application.
A hidden copy, a readonly flag or a correct value in developer tools is not authorization. The server must check who is acting, which fields may change and which source determines the value. If the UI and server requirements disagree, repair the contract rather than treating a correct-looking unnamed field as a completed submission.


