Making Telephone (numeric) keypad display on iPads | XM Community
Skip to main content
Question

Making Telephone (numeric) keypad display on iPads

  • April 12, 2022
  • 1 reply
  • 159 views

I've searched around and found some javascript that will force the numbers to appear on a standard iPad keyboard, as follows:
jQuery("#"+this.questionId+" .InputText").attr('type', 'tel');

But I would like to only show the numeric keypad. I saw some mention of

inputmode = numeric 
being supported for iOS devices and
pattern="[0-9]*" 
but I don't know how to integrate it with the above.
Any javascript pros know how to help?

1 reply

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • April 13, 2022

Hi there, try inputting the below JS. It will make it so that only the values 0-9 can be inputted.
jQuery("#"+this.questionId+" .InputText").attr( { type:"number", onkeydown:"if(event.key==='.'){event.preventDefault();}", oninput:"event.target.value = event.target.value.replace(/[^0-9]*/g,'');" } );