Input Datetime required property
Example
Check whether the datetime field is a required field before submitting the form:
var x = document.getElementById("myDatetime").required;
x
The output is:
true
Try it »
Definition and Usage
The required property is used to set or return whether the datetime field is a required field 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 the Safari browser.
Note: Supported by Internet Explorer, Firefox, Opera 15 (and later), or Chrome. element using type="datetime".
Syntax
Return the required attribute:
datetimeObject
.required
Set the required attribute:
datetimeObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the datetime field is a required part before form submission.
|
Technical Details
| Return Value: | Boolean, returns true if the datetime field is a required part of the form, otherwise returns false. |
|---|
More examples
Example
Set the datetime field as a required part of the form:
document.getElementById("myDatetime").required = true;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
Input Datetime Object