Input Month requiredProperty

Input Month 对象参考手册Input Month Object

Examples

Find out whether the month field is required before submitting the form:

var x = document.getElementById("myMonth").required;
xThe result is:
true

Try it Yourself »

Definition and Usage

The required property sets or returns whether the month field is a required field in the form.

This property reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

Note:Internet Explorer and Firefox do not support <input> elements with the type="month" attribute.


Syntax

Return the required property:

monthObject.required

Set the required property:

monthObject.required=true|false

Property Values

Value Description
true|false Specifies 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: A Boolean value, returns true if the month field is a required part of the form, otherwise returns false.


More Examples

Example

Set the month field to be a required part of the form:

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

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> required Attribute


Input Month 对象参考手册Input Month Object Other Extensions