Latest web development tutorials

HTML DOM Input Month required properties

Input Month Object Reference Input Month Object

Examples

View month field before submitting the form if required fields:

var x = document.getElementById("myMonth").required;
x The output is:
true

try it"

Definition and Usage

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

This property reflects the HTML required attributes.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required properties, in addition to Internet Explorer 9 and earlier versions of IE, Safari browser.

Note: Internet Explorer or Firefox browser does not support type = "month" <input> element attributes.


grammar

Returns required attributes:

monthObject .required

Set the required properties:

monthObject .required=true|false

Property Value

描述
true|false 描述了 month 字段在表单提交前是否为必填部分。
  • true - month 字段为表单的必填部分
  • false - 默认。 month 字段为表单的选填部分。

technical details

return value: Boolean value that, if the month field is required parts of the form back to true, otherwise false.


More examples

Examples

Set the month field of the form required parts:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input Month Object Reference Input Month Object