Input Date required Attribute

Definition and Usage

required Sets or returns whether the date field must be filled out before submitting the form.

This property reflects the HTML required attribute.

See also:

HTML Reference Manual:HTML <input> required Attribute

Example

Example 1

Determine whether the date field must be filled out before submitting the form:

var x = document.getElementById("myDate").required;

Try it yourself

Example 2

Set the date field as a required part of the form submission:

document.getElementById("myDate").required = true;

Try it yourself

Syntax

Return required attribute:

inputdateObject.required

Set required attribute:

inputdateObject.required = true|false

Attribute value

Value Description
true|false

Specify whether the date field should be a required part of the form submission.

  • true - The date field is a required part of the form submission
  • false - Default. The date field is not a required part of the form submission

Technical details

Return value: Boolean value, if the date field is a required part of the form submission, it returns true, otherwise return false.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="date"> element does not display any date field/calendar in IE11 and earlier versions.