← Community home

Why does disabled=”false” still disable an input?

Community › Forums › HTML Basics › Why does disabled=”false” still disable an input?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #50

    An input remains disabled even though its disabled attribute says false.

    #51

    Detailed answer

    A boolean attribute is true when present, even if its value is the text false.

    Remove disabled to enable the control, or set the corresponding DOM property to false. This rule does not apply to every attribute: ARIA attributes and other enumerated attributes have their own value rules.

    Example

    <input name="preview" disabled>
    <input name="editable">

    Understanding the behavior

    Boolean attributes are enabled by their presence, regardless of a string such as false. Remove disabled to enable the control, or update its JavaScript disabled property. Disabled controls also behave differently from read-only fields during form submission.

    Practical implementation notes

    Test keyboard focus and submitted data after changing the attribute. If a value must remain submitted but should not be editable, check whether readonly is supported by that control and fits the intended interaction.

    How to check it

    Remove the disabled attribute entirely, then try focusing and editing the control.

    Expected result

    The control becomes editable only when disabled is absent or its DOM property is false.

    Watch out: Do not apply HTML boolean syntax rules to aria-expanded.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.