The quick answer: a
readonly
input stops users from editing a field's value but still submits that value with the form and lets users focus and select it. A
disabled
input blocks editing too, but it also removes the field from focus, drops it from form submission entirely, and greys it out visually. So when you weigh
readonly vs disabled, the real question is whether you still want that value sent to your server.
Content Table
The core differences at a glance
Both attributes prevent a user from typing into a field, but everything else about them diverges. Here is the side-by-side breakdown.
| Behavior | readonly | disabled |
|---|---|---|
| User can edit the value | No | No |
| Value is submitted with the form | Yes | No |
| Field can receive focus | Yes | No |
| Text can be selected and copied | Yes | No |
| Included in tab order | Yes | No |
| Announced normally by screen readers | Yes | Often skipped or flagged as unavailable |
| Default visual style | Looks normal | Greyed out |
| Triggers HTML validation | No (readonly fields skip constraint validation) | No |
What readonly actually does
The
readonly
attribute locks the value so the user cannot change it, while treating the field as a fully live part of the form. The value gets sent when the form submits, the user can click into it, highlight the text, and copy it.
<input type="text" name="invoice_id" value="INV-20418" readonly>
Reach for readonly when the value matters to your backend but should not be touched by hand:
- An auto-generated invoice number, order ID, or reference code you want submitted as-is.
- A pre-filled email or account name that the user should see and confirm but not edit.
- A calculated total that updates via JavaScript but should not accept manual typing.
readonly
only applies to text-like inputs (text,
email,
number,
password,
search,
url,
tel) and
<textarea>. It has no effect on checkboxes, radio buttons, selects, or buttons. If you need to lock a
<select>, that is a case for disabled (plus a hidden field to carry the value).
What disabled actually does
The
disabled
attribute takes a field completely out of play. The browser greys it out, skips it in the tab order, blocks focus and selection, and, most importantly, leaves its value out of the submitted form data.
<input type="text" name="coupon" value="SAVE10" disabled>
In that example, when the form is submitted, no
coupon
key appears in the request at all. That is the single biggest trap people hit: they disable a field, then wonder why the value never reaches the server.
Use disabled when the field is genuinely unavailable right now:
- A submit button that stays off until a checkbox is ticked.
- A "State" dropdown that is inactive until the user picks a country.
- Options that don't apply to the current plan or selection and you don't want submitted.
When to use each one
A simple decision path:
- Should the value be submitted? If yes, you cannot use disabled. Use readonly (or disabled plus a matching hidden input carrying the same value).
- Should the user be able to select or copy the text? If yes, readonly. Disabled fields can't be selected.
- Is the field temporarily off because of another choice? That is classic disabled territory, like a button waiting on a condition.
These states matter most inside real forms, and they pair naturally with other choices you make about layout and behavior. If you are still deciding how a field itself should be built, our guide on choosing between a datalist and a select covers input types that also interact with these attributes. And once your fields are set, understanding where the HTML form action sends your data helps you predict exactly which values land on the server, disabled ones included (or rather, excluded).
Common gotchas and accessibility notes
- Disabled kills accessibility clues. Screen readers often skip disabled controls or announce them as unavailable, and keyboard users can't tab to them. If a user needs to read the value, readonly is far friendlier.
-
Readonly still shows validation quirks.
Per the
MDN readonly reference, readonly fields are barred from constraint validation, so a
requiredreadonly field will not block submission the way you might expect. - Client-side locks are not security. Both attributes only affect the browser. A user can edit the HTML in dev tools and change a readonly value or re-enable a disabled one. Always validate and re-check on the server.
- Styling differs. Readonly fields look normal, so add a subtle style (like a lighter background) so users notice they can't type. Disabled fields already look greyed out by default.
-
The disabled-plus-hidden trick.
When you want a select to look locked but still submit its value, mark the visible select
disabledand add a<input type="hidden">with the same name and value.
The official MDN documentation on the disabled attribute confirms these behaviors are consistent across modern browsers, so you can rely on them without vendor-specific workarounds.
Build a contact form that submits exactly the right fields
Whether you use readonly to lock a pre-filled value or disabled to hide one from submission, our contact form endpoint captures every field you actually send, no backend required.
Try our free contact form →
Frequently asked questions
Yes. A readonly input's value is included in the form submission exactly like a normal field. That is the main reason to choose readonly over disabled when you want the value on your server but don't want the user to change it by hand.
Because disabled fields are deliberately excluded from form data by the browser. To keep the value while showing the field as locked, either switch to readonly or add a hidden input with the same name and value alongside the disabled field.
Not directly. The readonly attribute only works on text-like inputs and textareas. For selects, checkboxes, and radios, use disabled to lock them, then add a hidden input carrying the value if you still need it submitted with the form.
No. Both are client-side only. Anyone can open browser dev tools, remove the attribute, and edit or submit the value. Treat them as user-experience hints, and always validate and sanitize every incoming value on the server before trusting it.
Readonly is generally friendlier. It stays in the tab order and gets announced by screen readers, so users can still read and copy the value. Disabled controls are often skipped by assistive tech and can't receive focus, which hides information from some users.