Input DatetimeLocal required attribute

Definition and Usage

required Attribute sets or returns whether the local date and 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-attribut

Example

Example 1

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

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

Try it yourself

Example 2

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

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

Try it yourself

Syntax

Return the required attribute:

datetimelocalObject.required

Set the required attribute:

datetimelocalObject.required = true|false

Attribute value

Value Description
true|false

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

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

Technical details

Return value: Boolean value, if the local date and time field is a required part of the form submission, it returns trueannars returnera false.

Webbläsarstöd

Numrerna i tabellen anger den första webbläsarens version som helt stöder detta attribut.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stödjer 10.0 Stödjer Stödjer Stödjer

Observera:Elementet <input type="datetime-local"> visar inga datum- eller tidsfält/kalender i Firefox.