Actaully i have two types of input types: one is normal text and another is radio type.I want to valdiate both the fields before submit button is entered.
For this normal input field i made the validation but i have no idea how to do for the radio button.I want to validate if user doesnot select any radio button.
<form name="form" #f="ngForm" (ngSubmit)="f.form.valid && onSubmit()" novalidate class="feedback-form">
<div class="col-md-12">
<div class="form-group col-md-4">
<label for="selectionDate">Selection Date</label>
<input type="text"
id="selectionDate"
class="form-control"
name="selectionDate"
placeholder="Please enter the date"
[(ngModel)]="selection.selectionDate"
#selectionDate="ngModel"
[ngClass]="{ 'is-invalid': f.submitted && selectionDate.invalid }"
required
/>
<div *ngIf="f.submitted && selectionDate.invalid" class="invalid-input">
<!-- individual validation errors -->
<div *ngIf="selectionDate.errors?.required">DateField is required</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="selectedBy">Selected By</label>
<br>
<label class="radio-inline">
<input type="radio" name="selectedBy"
[(ngModel)]="selection.selectedBy" value="Department">Department
</label>
<label class="radio-inline">
<input type="radio" name="selectedBy"
[(ngModel)]="selection.selectedBy" value="Office">Office
</label>
</div>
</div>
</form>