1

Is there a way to trigger the numeric keyboard for a <input type="text" /> field for all mobile devices?

I've tried both:

<input type="text" pattern="\d*" />

<input type="text" pattern="[0-9]*" />

But this only seems to trigger the numeric keyboard for iOS. Android still displays the default keypad.


Note: I'm trying to do a duration input, ie. HH:MM, so <input type="number" /> is not a solution for this as I need a input field that will accept numbers and colons.

I also don't mind using javascript if that's the only solution.

Ryan King
  • 3,538
  • 12
  • 48
  • 72

1 Answers1

-1

I didn't try this but I did see some solutions in the past:

<input type="number" pattern="[0-9]*" inputmode="numeric">

Or:

<input type="number" pattern="[0-9]*" required>

I think type=tel is also supported but never tried it:

<input type="tel">

Here you have few examples.

Mehdi
  • 408
  • 4
  • 12