Input Date required attribute
Example
Check whether the date field is required before form submission:
var x = document.getElementById("myDate").required;
x
The output is:
true
Try it »
Definition and Usage
The required attribute is used to set or return whether the date field is required before form submission.
This attribute reflects the HTML required attribute.
Browser support





All major browsers support the required attribute, except Safari and Internet Explorer 9 and earlier versions.
**Note:** Internet Explorer or Firefox browser does not support .
Syntax
Return the required attribute:
dateObject
.required
Set the required attribute:
dateObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the date field is a required field in the form.
|
Technical Details
| Return Value: | Boolean value, returns true if the date field is a required field in the form, otherwise returns false |
|---|
More examples
Example
Set the date field as a required part of the form:
document.getElementById("myDate").required = true;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
Input Date Object