splitforms.com

HTML · INPUT ATTRIBUTE

HTML readonly vs disabled: lock a field without losing its value

readonly stops a visitor from changing a field, but the field can still be focused and copied, and its value is submitted with the form. disabled locks the field completely: it can't be focused, it skips validation and its value is never sent. Use readonly when the backend needs the value, and disabled when it doesn't.

  • Live, editable example
  • Copy-paste snippet
  • Attributes & common mistakes
Live demo · nothing is sent

What gets submitted

Fill in the form above and press its button. The demo stops the request and lists every name=value pair the browser would send, plus the controls it leaves out.

With a free access key in the form, these fields land in your splitforms dashboard; access_key and botcheck are read by splitforms, not stored as lead data.

Edit the HTML and re-run it
Runs in a sandbox. Nothing is sent.

Minimal snippet

readonly-example.html
<input name="plan" value="Pro" readonly>

Want this form to email you its submissions? Point it at a free splitforms endpoint, with no server to build. Get a free access key →

Copy-paste code

HTML readonly & disabled code you can paste today.

Replace YOUR_ACCESS_KEY with a key from your free splitforms dashboard. The form posts to one endpoint — submissions land in your inbox and dashboard with spam filtering built in.

readonly.html
<form action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">

  <label for="order_id">Order ID</label>
  <input type="text" id="order_id" name="order_id" value="A-1042" readonly>

  <!-- disabled: shown, but never submitted -->
  <label for="internal_note">Internal note</label>
  <input type="text" id="internal_note" name="internal_note" value="not sent" disabled>

  <label for="email">Email</label>
  <input type="email" id="email" name="email" autocomplete="email" required>

  <label for="message">Message</label>
  <textarea id="message" name="message" rows="5" required></textarea>

  <!-- Honeypot: hidden from people, bots fill it in -->
  <input type="checkbox" name="botcheck" style="display:none">

  <button type="submit">Send</button>
</form>

readonly vs disabled

What is the difference between readonly and disabled?

A readonly field is submitted and can be focused. A disabled field is skipped on submit and can't be focused. Both skip validation.

What is the difference between readonly and disabled?
Behaviourreadonlydisabled
Submitted with the formYesNo
Can be focused and selected or copiedYesNo
In the tab orderYesNo
Validation like requiredSkippedSkipped
Works onText-like, number and date inputs and <textarea>. NOT <select>, checkbox, radio or file.Every form control, plus <fieldset>
CSS pseudo-class:read-only:disabled

Sources: WHATWG HTML Standard: constructing the entry list · MDN: HTML attribute readonly · MDN: HTML attribute disabled

Attributes · readonly

Which attributes go with readonly?

readonly and disabled lock a field in different ways. required and tabindex behave differently on each.

HTML readonly & disabled attributes and what each one does
AttributeWhat it does
readonlyThe value can't be edited, but the field can be focused and is still submitted.
disabledThe field can't be edited or focused, and its value is not submitted.
requiredMakes a field mandatory. It is skipped on readonly and disabled fields.
tabindexSets the tab order. A readonly field stays in it; a disabled field is always left out.

Common mistakes

readonly and disabled mistakes to avoid

Most locked-field bugs come from a value that wasn't sent or a control that ignores readonly.

  1. readonly does nothing on select, checkbox and radio

    Those controls ignore readonly. To lock one, make it disabled and add an <input type="hidden"> with the same name that carries the value.

  2. disabled values are never sent

    A disabled field is left out of the submission completely, even if it has a name and a value. Use readonly if the backend needs it.

  3. readonly is not security

    Anyone can edit the HTML or POST a changed value directly. Re-check locked values like prices or IDs on the server.

  4. A disabled fieldset disables every field inside it

    <fieldset disabled> disables all its controls, so none of them are submitted. Only controls inside its first <legend> stay enabled.

Sources: MDN: HTML attribute readonly · MDN: HTML attribute disabled

Key benefits

Copy-paste ready

The HTML readonly & disabled example below is a complete, working form — paste it into any HTML page and it submits, no edits to the markup required.

No backend to build

Your html readonly & disabled form posts to one endpoint. No server, PHP, or API route — accepted submissions are saved to your dashboard before owner notification email is attempted; delivery time and inbox placement depend on provider and recipient settings.

A form that really submits

Unlike a static reference snippet, this readonly form actually sends data to a free splitforms backend, with spam filtering built in.

How it works

How to add HTML readonly & disabled to any page.

Copy the html readonly & disabled example, drop in your free access key, and paste it into any page — submissions start landing in your dashboard.

  1. Copy the code

    Copy the HTML readonly & disabled example below.

  2. Add your access key

    Replace YOUR_ACCESS_KEY with a free splitforms key from the dashboard.

  3. Paste into your site

    Drop the form into any HTML page. Submissions arrive in your dashboard.

Questions

HTML readonly & disabled questions, answered.

Anything missing? Email us, we read every message.

A person reading answers to common questions
What is the difference between readonly and disabled?

Both stop a visitor from changing a field. A readonly field can still be focused and copied, and its value is submitted. A disabled field can't be focused, is left out of the tab order and its value is not submitted.

Why is my disabled input not submitted?

Disabled controls are never included in a form submission. Use readonly instead, or add a hidden input with the same name and value if the control has to stay disabled.

How do I make a select readonly?

A <select> ignores readonly. Set disabled on the select so it can't be changed, and add <input type="hidden"> with the same name and the chosen value so the value is still sent.

Does readonly skip required validation?

Yes. A readonly field is barred from constraint validation, so required, pattern and similar checks are not applied to it. Validate the value on the server instead.

How do I style readonly fields?

Use the :read-only pseudo-class or the input[readonly] selector, for example to give them a grey background so visitors can see they can't be edited. Disabled fields match :disabled.

View all FAQs

Make this form actually submit.

Point your form at splitforms. 500 free submissions a month, spam filtering, webhooks on paid plans — no server.

  • No credit card required
  • 500 free submissions
  • Setup in minutes
Two people celebrating a working contact form