我的 FormGroup 上有两个控件我需要验证两个控件中的至少一个才能提交表单
如果只有一个 FormControl 有效,我需要该 formGroup 有效
this.form = this.fb.group({
'keyWord' : new FormControl(null, [
Validators.required,
Validators.minLength(4)
]),
'name': new FormControl(null, [
Validators.required
])
});
html
<form [formGroup]="form" (ngSubmit)="isPending=!isPending;searchCriteria(form.value);" class="form-group" novalidate>
<small class="text-danger" *ngIf="?????">At Least One Field is required</small>
<div class="input-group box-shadow">
<div class="input-group-addon border-top-0 border-left-0 border-bottom-0 rounded-0">
<i class="fa fa-search"></i>
</div>
<input type="text" formControlName="keyWord" placeholder="" class="form-control border-0">
<input type="text" formControlName="name" placeholder="" class="form-control border-0">
<button type="submit" value="submit">
</form>