最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Show Decimal Keyboard in HTML5 iOS 7iOS 8 - Stack Overflow

programmeradmin0浏览0评论

I just have a simple question after having searched for hours now: Is there any possibility to show the decimal keyboard in webbrowsers input fields? input type="number" only shows numbers but i need a comma or dot instead in the bottom left corner.

I tried anything, pattern, step etc., but nothing brings up the decimal keyboard. I only need the numbers and a dot or comma, no A-Z or a-z or anything else.

<input type="number" id="inputNumbers" pattern="[0-9]*" size="30" min="1" max="5">

This is what i get:

This is what i want:

I just have a simple question after having searched for hours now: Is there any possibility to show the decimal keyboard in webbrowsers input fields? input type="number" only shows numbers but i need a comma or dot instead in the bottom left corner.

I tried anything, pattern, step etc., but nothing brings up the decimal keyboard. I only need the numbers and a dot or comma, no A-Z or a-z or anything else.

<input type="number" id="inputNumbers" pattern="[0-9]*" size="30" min="1" max="5">

This is what i get:

This is what i want:

Share Improve this question edited Jun 23, 2015 at 12:16 Sithys asked Jun 23, 2015 at 11:57 SithysSithys 3,7938 gold badges36 silver badges68 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 14

Checkout inputmode="decimal" starting on iOS 12.2

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode

https://caniuse.com/#feat=input-inputmode

This works for iPhone and Android:

<input type="text" inputmode="decimal">

Results in this keypad with iPhone 10:

And with Android:

https://github.com/mrchandoo/cordova-plugin-decimal-keyboard

Lets you configure the decimal character(instead of . you can change to , )

Try this:

EditText myEditText = (EditText)findViewById(R.id.myEditText);
myEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

Or:

<input type="tel" />

This is a bit of a hack:

<input type="number" step="0.01">

Might work depending on what you are trying to achieve when it comes to input values

This link might be useful: Force iOS numeric keyboard with custom / currency pattern

Hope you come right!

Check this html code according to your pattern

 <input type="text" pattern="[a-z]*">
发布评论

评论列表(0)

  1. 暂无评论