How can I validate my numeric input field to only accept integer and not any kind of decimal numbers (comma / dot)?
Component
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
this.savingData = this.formBuilder.group({
amount: ['', Validators.required], // only accept integer 123000
});
HTML
<ion-input type="number" min="1" inputmode="numeric" formControlName="amount" placeholder="{{ 'SAVINGS.amount' | translate }}" ></ion-input>
Any idea?
You can try Angular Reactive form pattern validator
this.savingData = this.formBuilder.group({
amount: ['', [Validators.required, Validators.pattern("^[0-9]*$")]], // only numbers
});