Input Time readOnly attribute

Definition and usage

readOnly Property to set or return whether the input field should be read-only.

You cannot modify read-only fields. However, users can select, highlight it, and copy text from it.

This property reflects the HTML readonly attribute.

Tip:To prevent users from interacting with the field, use disabled attribute.

See also:

HTML Reference Manual:Propriedade readonly do <input> do HTML

Instance

Example 1

Set the time field to read-only:

document.getElementById("myTime").readOnly = true;

Try it yourself

Example 2

Check if the time field is read-only:

var x = document.getElementById("myTime").readOnly;

Try it yourself

Syntax

Return readOnly property:

timeObject.readOnly

Set readOnly property:

timeObject.readOnly = true|false

Attribute value

Value Description
true|false

Specify whether the time field should be read-only.

  • true - The time field is read-only
  • false - Default. The time field is not read-only

Technical details

Return value: Boolean value, if the time field is read-only, it returns truede outra forma, retorna false.

Suporte do navegador

Os números na tabela indicam a versão do navegador que suporta plenamente essa propriedade.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Suporte 10.0 Suporte Suporte Suporte

Atenção:O elemento <input type="time"> não é exibido como campo de tempo em Firefox.