azerion / phaser-input

Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
MIT License
203 stars 64 forks source link

Numeric keyboard/input only but show password characters #66

Closed jesperjohansson closed 6 years ago

jesperjohansson commented 6 years ago

Is there a way to show the numeric keyboard on mobile devices but keep the type "password"? Or somehow only show the numbers as "*"?

jesperjohansson commented 6 years ago

Solved it like this:

    const input = this.game.make.inputField(x, y, {
      type: PhaserInput.InputType.password,
    });

    input.domElement.element.setAttribute('inputmode', 'numeric');
    input.domElement.element.setAttribute('pattern', '[0-9]*');
    input.domElement.element.type = 'number';