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
Show Decimal Keyboard in HTML5 iOS 7 / iOS 8
提问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
, 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.
我尝试新鲜事物,pattern
,step
等,但没有任何带来了十进制键盘。我只需要数字和一个点或逗号,不需要 AZ 或 az 或其他任何东西。
<input type="number" id="inputNumbers" pattern="[0-9]*" size="30" min="1" max="5">
This is what i get:
这就是我得到的:
This is what i want:
这就是我要的:
采纳答案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 ,
)
允许您配置十进制字符(而不是.
您可以更改为,
)
回答by vguerrero
Checkout inputmode="decimal"
starting on iOS 12.2
inputmode="decimal"
从 iOS 12.2 开始结帐
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
回答by Hari Om Srivastava
Check this html code according to your pattern
根据您的模式检查此 html 代码
<input type="text" pattern="[a-z]*">