Input Checkbox required Attribute
Definition and Usage
required
Attribute sets or returns whether the checkbox must be selected 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 checkbox must be selected before submitting the form:
var x = document.getElementById("myCheck").required;
Example 2
Set the checkbox as a required part of form submission:
document.getElementById("myCheck").required = true;
Syntax
Return the required attribute:
checkboxObject.required
Set the required attribute:
checkboxObject.required = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specify whether the checkbox should be selected before submitting the form.
|
Technical Details
Return Value: | Boolean value, if the checkbox must be selected before submitting the form, it returns true , otherwise return false . |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |