Input Datetime required attribute
Definition and usage
required
Attribute sets or returns whether the 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 date and time field must be filled out before submitting the form:
var x = document.getElementById("myDatetime").required;
Example 2
Set the date and time field as a required part of the form submission:
document.getElementById("myDatetime").required = true;
Syntax
Return the required attribute:
datetimeObject.required
Set the required attribute:
datetimeObject.required = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specify whether the date and time field should be a required part of the form submission.
|
Technical details
Return value: | Boolean value, if the date and time field is a required part of the form submission, it returns true ; wird zurückgegeben, wenn nicht false . |
---|
Browser-Unterstützung
Die in der Tabelle angegebenen Zahlen zeigen die erste Browserversion, die diesen Attribut vollständig unterstützt.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützt | 10.0 | Unterstützt | Unterstützt | Unterstützt |
Hinweis:Das Element <input type="datetime"> zeigt in allen gängigen Browsern außer Safari keine Datums- und Zeitfelder/Kalender an.