0

I have a requirement where I have an input field, that must have the prefix "APP " and then allow the user to type in 7 numeric only values. I was hoping I could use ngx-mask, but it doesn't seem possible. Alternatively I was thinking of using (focusin) event like:

(focusin)="addPrefix($event)"

inputValue = "";
addPrefix(ev: any){
 inputValue = "APP ";
}

and then having a keyup event which would disregard key presses if input.length <= 3.But then comes this issue of pasting values in. Does anyone else have any better ideas/suggestions? Thanks

jpuvo
  • 25
  • 1
  • 1
  • 5

1 Answers1

2

Stackblitz

How about,

<input type="text" prefix="APP " mask="0000000" [clearIfNotMatch]="true" />

using ngx-mask?

Andrew Allen
  • 6,512
  • 5
  • 30
  • 73
  • This is exactly what I was looking for. Not sure how I missed the prefix property in the docs. Thanks alot! – jpuvo May 26 '22 at 19:58