Easy Tutorial
❮ Met Win Getselection Prop Number Autofocus ❯

Input DatetimeLocal required Attribute

Input DatetimeLocal Object

Example

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

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

Definition and Usage

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

This attribute reflects the HTML required attribute.


Browser Support

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

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


Syntax

Return the required attribute:

Set the required attribute:

Attribute Values

Value Description
true|false Describes whether the local time field is required before form submission. true - The local time field is mandatory in the form. false - Default. The local time field is optional in the form.

Technical Details

| Return Value: | Boolean, returns true if the local time field is mandatory in the form, otherwise returns false. | | --- | --- |


More Examples

Example

Set the local time field as mandatory in the form:

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

Related Pages

HTML Reference: HTML <input> required Attribute


❮ Met Win Getselection Prop Number Autofocus ❯