Latest web development tutorials

HTML DOM Input Date required properties

Input Date Object Reference Input Date Object

Examples

See date fields before the form is submitted if it is a required field:

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

try it"

Definition and Usage

required attribute is used to set or return date fields before the form is submitted if required.

This property reflects the HTML required attributes.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


grammar

Returns required attributes:

dateObject .required

Set the required properties:

dateObject .required=true|false

Property Value

描述
true|false 描述了 date 字段是否为表单中的必填字段。
  • true - date 字段为表单中必填字段
  • false - 默认。 date 字段不是表单中必填字段

technical details

return value: Boolean value that, if the date fields are required fields in a form returns true, false otherwise


More examples

Examples

Set the date field in the form of required parts:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input Date Object Reference Input Date Object