Input Datetime requiredProperty
Example
Check whether the datetime field is required before submitting the form:
var x = document.getElementById("myDatetime").required;
xThe output is:true
Try it Yourself »
Definition and Usage
The required property sets or returns whether the datetime field is a required field in the form.
This property reflects the HTML required attribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the required property, except Internet Explorer 9 and earlier IE versions, and Safari.
Note:Internet Explorer, Firefox, Opera 15 (and later versions), or Chrome support the <input> element with type="datetime".
Syntax
Return the required property:
datetimeObject.required
Set the required property:
datetimeObject.required=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Describes whether the datetime field is a required part of the form before submission.
|
Technical Details
| Return Value: | A Boolean, returning true if the datetime field is a required part of the form, otherwise it returns false. |
|---|
More Examples
Example
Set the datetime field as a required part of the form:
document.getElementById("myDatetime").required = true;
Try it Yourself »
Related Pages
HTML Reference:HTML <input> required attribute
Input Datetime Object Other Extensions