<select name="tenure"
formControlName="tenure"
class="form-control"
(change)="TenureChange($event.target.value)">
<option value="0">--select--</option>
<option *ngFor="let tenur of ddltenure">{{tenur}}</option>
</select>
<span class="validation-block"
*ngIf="!planmodeForm.get('tenure').valid && planmodeForm.get('tenure').touched">
Please select tenure
</span>
在我的组件中
this.planmodeForm = new FormGroup({
'planmode': new FormControl(null, [Validators.required, Validators.pattern(this.planmodePattern)]),
'tenure': new FormControl(null, Validators.required),
'maxstudents': new FormControl(null, Validators.required),
'maxusers': new FormControl(null, Validators.required),
'notificationconf': new FormArray([])
});
当slect选项更改为0
时,我想使表单无效答案 0 :(得分:2)
value="0"
应为value=""
required
验证。