Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Time required property

Input Time required property

Input Time Object Reference Input Time Object

Example

Check whether the time field is a required field before submitting the form:

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

x

The output is:

true

Try it »


Definition and Usage

The required property sets or returns whether the time field is required in the form.

This attribute reflects the HTML required attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required attribute, except Internet Explorer 9 and earlier versions and the Safari browser.

Note: Internet Explorer or Firefox browsers do not support HTML using the type="time" attribute .


Syntax

Return the required attribute:

timeObject

.required

Set the required attribute:

timeObject

.required=true|false

Attribute values

Value Description
true|false Describes whether the time field is a required part before the form is submitted.
  • true - the time field is a required part of the form
  • false - default. The time field is an optional part of the form.
  • |

    Technical Details

    Return Value: Boolean value, returns true if the time field is a required part of the form, otherwise returns false.

    More examples

    Example

    Set the time field as a required part of the form:

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

    Try it »


    Related pages

    HTML required attribute


    Input Time Object Reference Input Time Object