0

I have an <input type="text"> element, which I have decided to use instead of type="number" so that I can format currency with commas, and I would like to use the number keyboard for my mobile users. The existing solutions I have found require a pattern="[0-9]*", but I need a pattern for my validation as well.

Codepen here.

How can I use the number keyboard without changing the pattern of my input or the type?

Community
  • 1
  • 1
user1429980
  • 6,872
  • 2
  • 43
  • 53
  • You cannot *force* a numeric keyboard, and the odds of having it successfully *suggested* are small if you want to use `input type=text`. I’m pretty sure this question has been asked before at SO. – Jukka K. Korpela Aug 25 '14 at 17:22

1 Answers1

0

Although it doesn't work yet on mobile browsers (keyboard still remains text), we may be able to use the inputmode attribute to set the keyboards on text elements.

I have done up a codepen to test this (not working in latest chrome on Android). Perhaps we will see this implemented in the near future.

user1429980
  • 6,872
  • 2
  • 43
  • 53