Input Time requiredProperty

Input Time 对象参考手册Input Time Object

Examples

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

var x = document.getElementById("myTime").required;
xThe output result is:
true

Try it Yourself »

Definition and Usage

The required property is used to set or return whether the time field is a required field in the form.

This property reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


Syntax

Return the required property:

timeObject.required

Set the required property:

timeObject.required=true|false

Property 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

Examples

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

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

Try it Yourself »


Related Pages

HTML <input> required Attribute
Input Time 对象参考手册Input Time Object Other Extensions