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

HTML DOM Input DatetimeLocal required attribute

Input DatetimeLocal required attribute

Input DatetimeLocal Object Reference Input DatetimeLocal Object

Example

Check whether the local datetime field is required before submitting the form:

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

x

The output is:

true

Try it »


Definition and Usage

The required attribute is used to set or return whether the local datetime 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 browser does not support .


Syntax

Return the required attribute:

datetimelocalObject

.required

Set the required attribute:

datetimelocalObject

.required=true|false

Attribute values

Value Description
true|false Describes whether the local datetime field is a required part before form submission.
  • true - the local datetime field is a required part of the form
  • false - default. the local datetime field is an optional part of the form.
  • |

    Technical Details

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

    More examples

    Example

    Set the local datetime field as a required part of the form:

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

    Try it »


    Related pages

    HTML Reference Manual: HTML required attribute


    Input DatetimeLocal Object Reference Input DatetimeLocal Object