Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

disabled: remove a control from interaction and submission

Distinguish disabled controls from read-only fields and security permissions.

Version: HTML Living Standard

Syntax

<fieldset disabled><legend>...</legend>...</fieldset>

The boolean disabled attribute disables applicable form controls. They are normally excluded from submission and constraint validation. A disabled fieldset also disables descendants, except those inside its first legend. Options and option groups have their own disabled rules. A stylesheet link uses the same attribute for a separate stylesheet-loading and application mechanism.

Presence enables the disabled state, even with the textual value false. It is not equivalent to readonly: a read-only text field can still be submitted. JavaScript may change disabled controls, and client-side disabling never replaces server authorization. Merely adding this attribute to an ordinary link does not disable that link.

The fixture submits the field inside the first legend and a read-only field, but omits the disabled required field. Validation succeeds because the disabled field is excluded. The test checks that exception and the actual submitted field names.

Examples

<!doctype html><meta charset="utf-8">
<form id="form"><fieldset disabled><legend><label>Kept <input name="kept" value="A"></label></legend><label>Omitted <input id="omitted" name="omitted" required></label></fieldset>
<label>Read only <input name="readOnly" value="B" readonly></label></form><output id="result"></output><script>
const form = document.querySelector('#form');
document.querySelector('#result').textContent = 'fields=' + [...new FormData(form).keys()].join(',') + '; valid=' + form.checkValidity() + '; disabledWillValidate=' + document.querySelector('#omitted').willValidate;
</script>

Result

fields=kept,readOnly; valid=true; disabledWillValidate=false

The required disabled field is empty; its exclusion from validation is verified explicitly.

Sources