<input class="input" pInputText [disabled]="disabled" [(ngModel)]="data.input.value"
(change)="inputOnChanges()" (keypress)="keyPress($event)" >
.ts file
const pattern = /^[+]?([0-9]+(?:[.][0-9]*)?|.[0-9]+)$/;
console.log('event is::',event);
const inputChar = String.fromCharCode(event.charCode);
if (!pattern.test(inputChar)) {
// invalid character, prevent input
event.preventDefault();
}
I am using above regex. Also, it says charCode is deprecated.