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

HTML DOM Input Date required attribute

Input Date required attribute

Input Date Object Reference Input Date Object

Example

Check whether the date field is required before form submission:

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

x

The output is:

true

Try it »


Definition and Usage

The required attribute is used to set or return whether the date field is required before form submission.

This attribute reflects the HTML required attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

**Note:** Internet Explorer or Firefox browser does not support .


Syntax

Return the required attribute:

dateObject

.required

Set the required attribute:

dateObject

.required=true|false

Attribute values

Value Description
true|false Describes whether the date field is a required field in the form.
  • true - the date field is a required field in the form
  • false - default. the date field is not a required field in the form
  • |

    Technical Details

    Return Value: Boolean value, returns true if the date field is a required field in the form, otherwise returns false

    More examples

    Example

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

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

    Try it »


    Related pages

    HTML Reference Manual: HTML required attribute


    Input Date Object Reference Input Date Object