Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Month required Property

Input Month required Property

Input Month Object Reference Input Month Object

Example

Check whether the month field is a required field before submitting the form:

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

x

The output is:

true

Try it »


Definition and Usage

The required property is used to set or return whether the month field is a required field in the form.

This attribute reflects the HTML required attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required attribute, except Internet Explorer 9 and earlier versions and the Safari browser.

**Note:** Internet Explorer or Firefox browsers do not support the HTML using the type="month" attribute .


Syntax

Return the required attribute:

monthObject

.required

Set the required attribute:

monthObject

.required=true|false

Attribute values

Value Description
true|false Describes whether the month field is a required part before the form is submitted.
  • true - the month field is a required part of the form
  • false - default. The month field is an optional part of the form.
  • |

    Technical Details

    Return Value: Boolean, returns true if the month field is a required part of the form, otherwise returns false.

    More examples

    Example

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

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

    Try it »


    Related pages

    HTML Reference Manual: HTML required attribute


    Input Month Object Reference Input Month Object