Input DatetimeLocal requiredProperty
Example
Check whether the local time field is required before submitting the form:
var x = document.getElementById("myLocalDate").required;
xThe output result is:true
Try it Yourself »
Definition and Usage
The required property is used to set or return whether the local time field is a required field in the form.
This property reflects the HTML required attribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the required attribute, except Internet Explorer 9 and earlier versions of IE, and Safari.
Note:Internet Explorer or Firefox do 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 | Describes whether the local time field is required before submitting the form.
|
Technical Details
| Return value: | A Boolean value, 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 Other Extensions