Input DatetimeLocal required attribute
Example
Check whether the local datetime field is required before submitting the form:
var x = document.getElementById("myLocalDate").required;
x
The output is:
true
Try it »
Definition and Usage
The required attribute is used to set or return whether the local 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:** Internet Explorer or Firefox browser does not support .
Syntax
Return the required attribute:
datetimelocalObject
.required
Set the required attribute:
datetimelocalObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the local datetime field is a required part before form submission.
|
Technical Details
| Return Value: | Boolean value, returns true if the local datetime field is a required part of the form, otherwise returns false. |
|---|
More examples
Example
Set the local datetime field as a required part of the form:
document.getElementById("myLocalDate").required = true;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
Input DatetimeLocal Object