jeudi 23 mai 2019

How to enable required text field on submit only in an Angular 5 app?

I have the following template with textbox:

<input type="checkbox" id="s_i" name="s_i" (change)="clickObj($event, myObjs[i])" [(ngModel)]="myObjs[i].isSelected">
<input type="text" [ngModelOptions]="{ updateOn: 'blur' }" [required]="myObjs[i].isSelected"
 id="f_p_" name="p_p_" [(ngModel)]="myObjs[i]">

When clicking on the checkbox the textfield become red automatically and not let the user a chance to enter value. I need to mark error only when clicking submit. Any idea what should I change/add in order fix this ? Thanks.




Aucun commentaire:

Enregistrer un commentaire