CheckboxRequiredValidator
From Get docs
< @angular/formsAngular/docs/8/api/forms/checkboxrequiredvalidator
CheckboxRequiredValidator
directive
A Directive that adds the required
validator to checkbox controls marked with the required
attribute. The directive is provided with the NG_VALIDATORS
multi-provider list.
See also
NgModules
-
FormsModule
-
ReactiveFormsModule
Selectors
input[type=checkbox][required][formControlName]
input[type=checkbox][required][formControl]
input[type=checkbox][required][ngModel]
Inherited from RequiredValidator
@Input()required: boolean | string
Description
Adding a required checkbox validator using template-driven forms
The following example shows how to add a checkbox required validator to an input attached to an ngModel binding.
<input type="checkbox" name="active" ngModel required>
Methods
validate() | |||
---|---|---|---|
Method that validates whether or not the checkbox has been checked. Returns the validation result if enabled, otherwise null. | |||
validate(control: AbstractControl): ValidationErrors | nullParameters
Returns
|
Inherited from RequiredValidator
validate(control: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void): void
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v8.angular.io/api/forms/CheckboxRequiredValidator