Input Month required Attribute

Definition and Usage

required Sets or returns whether the month 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 month field must be filled out before submitting the form:

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

Try it yourself

Example 2

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

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

Try it yourself

Syntax

Return the required attribute:

monthObject.required

Set the required attribute:

monthObject.required = true|false

Attribute value

Value Description
true|false

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

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

Technical Details

Return value: Boolean value, returned if the month field is a required part of the form submission true; otherwise return false.

Browser Support

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

Note:The <input type="month"> element does not display any date field/calendar in Firefox.