Input DatetimeLocal requiredProperty

Input DatetimeLocal 对象参考手册Input DatetimeLocal Object

Example

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

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

Try it Yourself »

Definition and Usage

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

This property reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

Note:Internet Explorer or Firefox do not support the <input type="datetime-local"> element.


Syntax

Return the required property:

datetimelocalObject.required

Set the required property:

datetimelocalObject.required=true|false

Property Values

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

Technical Details

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


More Examples

Example

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

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

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> required attribute


Input DatetimeLocal  对象参考手册Input DatetimeLocal Object Other Extensions