# Bad value X for attribute “readonly” on element “input”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-readonly-on-element-input
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `readonly` attribute is a boolean attribute, so it takes no value: `readonly="true"` is invalid, and so is any value other than an empty string or `readonly` itself.

The HTML standard allows three forms for a boolean attribute: the bare name (`readonly`), an empty value (`readonly=""`) and the name as its own value (`readonly="readonly"`). Browsers only check whether the attribute is there. `readonly="false"` still makes the field read-only, which surprises anyone who wrote it to switch the attribute off. To make the field editable, leave the attribute out.

The `"true"` value usually comes from a template or a JavaScript framework that prints a boolean variable as text, or from markup copied from the DOM, where `input.readOnly = true` is correct. In HTML, print the attribute when the field should be read-only and skip it when it shouldn't.

## Invalid example

```html
<label for="order-id">Order number</label>
<input type="text" id="order-id" name="order-id" value="A-1042" readonly="true">
```

## Valid example

```html
<label for="order-id">Order number</label>
<input type="text" id="order-id" name="order-id" value="A-1042" readonly>
```
