I have created a reactive form in angular. I am able to get the validation of the control on its touch, But not getting validated on the submission of the form by click on the submit button. My code is as like below :
<form [formGroup]="myform" (ngSubmit)="SubmitDetails()">
<div class="row">
<label for="name">Name:</label>
<input type="text" id="Name" name="Name" formControlName="Name"/>
<span *ngIf="myform.controls.Name.invalid && myform.controls.Name.touched">Please Enter Name.</span>
</div>
<br/>
<div class="row">
<label for="age">Age:</label>
<input type="text" id="Age" name="Age" formControlName="Age"/>
<span *ngIf=" myform.controls.Age.invalid && myform.controls.Age.touched">Please Enter Age.</span>
</div><br/>
<button type="submit">Submit</button>
</form>
<button type="submit" (click)="SubmitDetails()">Submit</button>- Emilienmyform.controls.Name.invalid && (myform.controls.Name.touched || myForm.submitted)- Arcteezy