Input Week required attribute

Definition and Usage

required Attribute set or return whether the week field must be filled out before submitting the form.

This property reflects the HTML required attribute.

See also:

HTML Reference Manual:HTML <input> required Attribute

Example

Example 1

Determine whether the week field must be filled out before submitting the form:

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

Try it yourself

Example 2

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

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

Try it yourself

Syntax

Return the required attribute:

weekObject.required

Set the required attribute:

weekObject.required = true|false

Attribute value

Value Description
true|false

Define whether the week field should be a required part of the form submission.

  • true - The week field is a required part of the form submission.
  • false - Default. The week field is not a required part of the form submission.

Technical Details

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

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="week"> element does not display any date field/calendar in Firefox.