I am trying to build a Search form with some filters. However, can't figure out how to configure ages range inputs (age from & to inputs). Here is the code:
type Script
export class SearchComponent implements OnInit {
SearchForm: FormGroup;
forbiddenEmails: any;
errorMessage: string;
constructor (
{
}
ngOnInit() {
this.nav.hide();
this.SearchForm = new FormGroup({
'name': new FormControl(null, [Validators.required,
Validators.pattern('(?=.*[a-z])(?=.*[A-Z])'),
]),
});
}
onSubmit() {
this.SearchForm.reset();
}
HTML
<div class="container">
<div class='row row1'>
<div class="col-md-12"
<form action="" [formGroup]="SearchForm" (ngSubmit)="onSubmit()">
<div class="form-group form-search">
<input _ngcontent-c0="" class="form-control form-control-lg" placeholder="name" type="text" id="name" formControlName="Name"/>
<span *ngIf="!SearchForm.get('name').valid && SearchForm.get('name').touched" class="help-block">Please enter a valid name!</span>
</div>
</div>
<div class='row'>
<div class="col-md-6"
<div class="input-group">
<input type="text" class="form-control" placeholder="Age From">
</div>
<div class="col-md-6"
<div class="input-group">
<input type="text" class="form-control" placeholder="To">
</div>
</div>
<div class="row">
<div class="col-md-4">
<button type="submit" class=" btn form-btn btn-lg btn-block">Search</button>
</div>
</div>
</div>
How can I configure the last 2 inputs called age from and to which must be used for age ranges like ages from 18 - 65 for example. So people can filter the results between the ages which they type on those 2 inputs?