javascript 在 HTML5 iOS 7 / iOS 8 中显示十进制键盘

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31002146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 13:06:06  来源:igfitidea点击:

Show Decimal Keyboard in HTML5 iOS 7 / iOS 8

javascriptioshtmlcsscordova

提问by Sithys

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.

在搜索了几个小时后,我只有一个简单的问题:是否有可能在网络浏览器输入字段中显示十进制键盘?input type="number"只显示数字,但我需要在左下角用逗号或点代替。

I tried anything, pattern, stepetc., 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.

我尝试新鲜事物,patternstep等,但没有任何带来了十进制键盘。我只需要数字和一个点或逗号,不需要 AZ 或 az 或其他任何东西。

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

This is what i get:enter image description here

这就是我得到的:在此处输入图片说明

This is what i want:enter image description here

这就是我要的:在此处输入图片说明

采纳答案by Dave

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

此链接可能有用: Force iOS numeric keyboard with custom /currency pattern

Hope you come right!

希望你来对!

回答by Chandra Sekhar Walajapet

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

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

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

允许您配置十进制字符(而不是.您可以更改为,

enter image description here

在此处输入图片说明

回答by Hari Om Srivastava

Check this html code according to your pattern

根据您的模式检查此 html 代码

 <input type="text" pattern="[a-z]*">

回答by Kai Noack

This works for iPhone and Android:

这适用于 iPhone 和 Android:

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

Results in this keypad with iPhone 10:

使用 iPhone 10 生成此键盘的结果:

iPhone 10 Decimal Keypad

iPhone 10 十进制小键盘

And with Android:

和安卓:

Android Decimal Keypad

安卓十进制小键盘