primeng icon indicating copy to clipboard operation
primeng copied to clipboard

p-inputotp: Integer Only attribute is not working on mobile

Open Bock92 opened this issue 1 year ago • 7 comments

Describe the bug

I have this code on my angular component: <p-inputotp variant="filled" [integerOnly]="true" [length]="6" [mask]="true" (onChange)="updatePinInput($event.value)" />

When the component is rendered on mobile browser the user is able to type alphabetic characters.

I have followed the doc example https://primeng.org/inputotp#integeronly but is not working

Environment

Angular 18.2.11 with PrimeNG 18

Reproducer

No response

Angular version

18.2.11

PrimeNG version

18.0.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

22.11.0

Browser(s)

All mobile browser

Steps to reproduce the behavior

No response

Expected behavior

No response

Bock92 avatar Dec 17 '24 15:12 Bock92

Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles:

github-actions[bot] avatar Dec 19 '24 14:12 github-actions[bot]

https://stackblitz.com/edit/xke2hbp3-cqalpqsr?file=src%2Fapp%2Finput-otp-sample-demo.html Could you try this StackBlitz example while this issue is being solved ?

tolgatopkara avatar Jan 12 '25 05:01 tolgatopkara

Got this problem too on v19.1 ... It's quite blocking...

https://stackblitz.com/edit/xke2hbp3-cqalpqsr?file=src%2Fapp%2Finput-otp-sample-demo.html Could you try this StackBlitz example while this issue is being solved ?

Your example is good but backspace doesn't work...

Afkarnir avatar Apr 29 '25 08:04 Afkarnir

Yup also experiencing this, on mobile you have to manually select numbers, then it keeps jumping back to alpha characters

mkutowski avatar Nov 17 '25 10:11 mkutowski

Same problem in v20

basven1997 avatar Nov 17 '25 20:11 basven1997

I create directive to fix this:

@Directive({
  selector: '[appNumericInput]',
})
export class NumericInputDirective implements AfterViewInit {
  private el = inject<ElementRef<HTMLElement>>(ElementRef);

  ngAfterViewInit() {
    const inputs = this.el.nativeElement.querySelectorAll('input');

    inputs.forEach(element => {
      element.setAttribute('inputmode', 'numeric');
    });
  }
}

and then

<p-inputotp
    appNumericInput
    [integerOnly]="true"
/>

frenzymind avatar Dec 04 '25 04:12 frenzymind

Problem Solved in V20.4.0 👍 https://github.com/primefaces/primeng/pull/19086

basven1997 avatar Dec 09 '25 12:12 basven1997

Same problem in version 21. Works in documents but doesn't work in my code.

html

ts imports :[ FormsModule, InputOtp]

value: any

mohamedhassan4475 avatar Dec 11 '25 10:12 mohamedhassan4475