HTML DOM Input Week required Attribute
Input Week required Attribute
Example
Check if the week field is a required field before submitting the form:
var x = document.getElementById("myWeek").required;
x output will be:
true
Definition and Usage
The required property sets or returns whether the week field in a form must be filled out before submitting the form.
This property reflects the HTML required attribute.
Browser Support
The required property is supported in all major browsers, except Internet Explorer 9 and earlier, and Safari.
Note: Internet Explorer and Firefox do not support the <input type="week"> element.
Syntax
Return the required property:
weekObject.required
Set the required property:
weekObject.required=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Specifies whether the week field must be filled out before submitting the form.
|
Technical Details
| Return Value: | A Boolean. Returns true if the week field is a required part of the form, otherwise it returns false. |
|---|
More Examples
Example
Set the week field as a required part of the form:
document.getElementById("myWeek").required = true;
Related Pages
HTML Reference: HTML <input> required Attribute
YouTip