简体   繁体   中英

Mobile Safari - Invoke Secondary Keyboard on input type=“text”

<input type="text"> brings up this keyboard:

文字键盘

while <input type="number"> brings up this one:

数字/辅助键盘

Is there a way to keep the input type text and invoke the second keyboard? perhaps with a pattern attribute?

My issue with input type="number" is that the user is expected to input fractions and $("#input_id").val(); is having trouble with space and forward slash, eg 3 5/6 returns 3 and 7/13 returns 7 .

if this can be bypassed i can also work with that.

<input type="text"> will always invoke primary keyboard.

What you can do is:

  • Prevent user from typing any character other than 0-9 and .(dot) by checking keycode or by regular expression
    eg: [0-9][.][0-9]{1-2} returns true for one or two decimal places.
  • Add some validation rule to the input field and show error when user submits the form

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM