{ "id": "api/forms/CheckboxRequiredValidator", "title": "CheckboxRequiredValidator", "contents": "\n\n
\n
\n
\n \n API > @angular/forms\n
\n \n
\n \n
\n

CheckboxRequiredValidatorlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

A Directive that adds the required validator to checkbox controls marked with the\nrequired attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

\n\n \n
\n \n \n \n \n
\n

See alsolink

\n \n
\n\n\n

NgModuleslink

\n\n\n\n \n
\n

Selectorslink

\n \n
    \n
  • input[type=checkbox][required][formControlName]
  • \n \n
  • input[type=checkbox][required][formControl]
  • \n \n
  • input[type=checkbox][required][ngModel]
  • \n \n
\n \n
\n\n\n\n \n\n\n\n\n
\n

Inherited from RequiredValidatorlink

\n \n
\n\n\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n \n

Adding a required checkbox validator using template-driven formslink

\n

The following example shows how to add a checkbox required validator to an input attached to an\nngModel binding.

\n\n<input type=\"checkbox\" name=\"active\" ngModel required>\n\n\n
\n \n\n \n\n \n\n \n\n \n\n\n\n\n \n \n\n
\n
\n\n\n" }