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

HTML DOM Input Week required property

Input Week required property

Input Week Object Reference The Input Week object

Example

Check whether the week field is required before submitting the form:

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

x

The output is:

true

Try it »


Definition and Usage

The required property sets or returns whether the week field is required in a 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 browsers do not support .


Syntax

Return the required attribute:

weekObject

.required

Set the required attribute:

weekObject

.required=true|false

Attribute values

Value Description
true|false Describes whether the week field is a required part before the form is submitted.
  • true - the week field is a required part of the form
  • false - default. The week field is an optional part of the form.
  • |

    Technical Details

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

    More examples

    Example

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

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

    Try it »


    Related pages

    HTML Reference Manual: HTML required attribute


    Input Week Object Reference The Input Week object