I have an angular4 application with a form. In this one I have an input to enter a percentage. So, I want to block the input with value between 0 and 100.
I tried to add
[I assume the reader has basic knowledge of Angular2+ and Forms]
It is easy to show a numerical input and put the limits, but you have to also take care of things may happen out of your predictions.
import { FormGroup, FormControl, Validators } from '@angular/forms';
//many other things...
this.myFG = new FormGroup({
//other form controls...,
rateFC : new FormControl(0, [Validators.min(0), Validators.max(100)])
});
.form-control.ng-touched.ng-invalid{
border:2px solid red;
}