Input Time required Attribute

Definition and Usage

required Set or return whether the time field must be filled out before submitting the form.

This property reflects the HTML required attribute.

See Also:

HTML Reference Manual:HTML <input> required Attribute

Example

Example 1

Determine whether the time field must be filled out before submitting the form:

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

Try It Yourself

Example 2

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

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

Try It Yourself

Syntax

Return the required attribute:

timeObject.required

Set the required attribute:

timeObject.required = true|false

Attribute Value

Value Description
true|false

Specify whether the time field should be a required part of the form submission.

  • true - The time field is a required part of the form submission
  • false - Default. The time field is not a required part of the form submission

Technical Details

Return value: Boolean value, returned if the time field is a required part of the form submission true, otherwise return false.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="time"> element does not display as any time field in Firefox.