Input Time readOnly attribute

Definition and usage

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

Read-only fields cannot be modified. 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:Atributo readonly del <input> en HTML

Instance

Example 1

Set the time field to read-only:

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

Try it yourself

Example 2

Find out 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 lo contrario, regresa false.

Compatibilidad del navegador

Los números en la tabla indican la versión del navegador que admite completamente la propiedad.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Soporte 10.0 Soporte Soporte Soporte

Atención:El elemento <input type="time"> no se muestra como ningún campo de tiempo en Firefox.