Latest web development tutorials

HTML DOM Input Datetime readOnly property

Input Datetime Object Reference Input Datetime Object

Examples

Datetime field is set to read-only:

. Document.getElementById ( "myDatetime") readOnly = true;

Output:


try it"

Definition and Usage

readOnly property sets or returns datetime field is read-only.

Read-only fields can not be modified. But you can copy the contents of the field.

This property reflects the HTML readonly attribute.

Tip: To ensure the accuracy of the form data, you can use the disabled property instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support readOnly property.

Note: Internet Explorer, Firefox, Opera 15 ( and higher) or Chrome supports the <input> element using type = "datetime".


grammar

Back readOnly attributes:

datetimeObject .readOnly

Set readOnly properties:

datetimeObject .readOnly = true | false

Property Value

value description
true | false Describes a datetime field is read-only
  • true - datetime field is read-only
  • false - default. datetime field is not read-only

technical details

return value: Boolean value that, if the datetime field is read-only returns true, otherwise returns false.


More examples

Examples

See datetime field is read-only:

var x = document.getElementById ( "myDatetime") readOnly.;
x The output is:
true

try it"


related articles

HTML Reference Manual: HTML <the INPUT> Readonly property


Input Datetime Object Reference Input Datetime Object