How to prevent form field to take nagetive value?


In form some this field “ml_right_wall” auto patched to “distance” variable. I want to prevent them if variable assign negative value to form field.


and want to display that field in red color if value patch comes in negetive

 <ion-input   type="number" min="0" formControlName="ml_right_wall" required clearInput></ion-input>


Explore using validators that you can add to your formGroup. This is an Angular feature. I use this module for my Ionic apps: