YouTip LogoYouTip

Prop Datetime Local Required

HTML DOM Input DatetimeLocal required Attribute

HTML DOM Input DatetimeLocal required Attribute

-- Learning not just technology, but dreams!

JavaScript Reference Manual

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<input> - datetime

<input> - email

Input DatetimeLocal required Attribute

Input DatetimeLocal Object Reference Manual Input DatetimeLocal Object

Example

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

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

x output result is:

true

Try it yourself Β»


Definition and Usage

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

This attribute reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The required attribute is supported in all major browsers, except Internet Explorer 9 and earlier IE versions, and Safari.

Note: Internet Explorer or Firefox does 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 Specifies whether the local time field is a required part of the form submission.
  • 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. 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 Object Reference Manual Input DatetimeLocal Object

← Prop Datetime Local TypeProp Datetime Local Readonly β†’