简体   繁体   English

移动Safari - 如何默认为十进制输入的完整数字小键盘w / o type =“number”,或禁用Safari输入类型=“数字”更正

[英]Mobile Safari - How to Default to Full Numeric Keypad for Decimal Entry w/o type=“number”, or disable Safari input type=“number” correction

I have a fairly basic but frustrating problem, essentially I've been trying to force input fields to behave more like text input types (where they do not correct incorrect number entries, such as "0..7" to truncate to "0") and just let JS form validation and backend validation do its job. 我有一个相当基本但令人沮丧的问题,基本上我一直在试图强制输入字段的行为更像文本输入类型(他们不纠正错误的数字条目,如“0..7”截断为“0”并且让JS表单验证和后端验证完成它的工作。 However, while I want to allow the user to enter whatever they want in the field (input type="text"), I want to FULL numberpad keyboard to display. 但是,虽然我想让用户在字段中输入他们想要的任何内容(输入类型=“文本”),但我想要显示全键盘键盘。

Original: 原版的:

<input type="number" name="test" class="answers" id="mileage" value="0.0" maxlength=5 />

Attempts to fix: 尝试修复:

Works on iPad, but NOT on iPods, as iPods display the compact number pad WITHOUT decimal points: 适用于iPad,但不适用于iPod,因为iPod显示紧凑的数字键盘没有小数点:

<input type="text" name="test" class="answers" id="mileage" value="0.0" maxlength=5 pattern="\d*"/>

Doesn't work on iPod, as it displays the full text keyboard, but doesn't default to the "number side" of the full keyboard with a decimal: 在iPod上不起作用,因为它显示全文键盘,但不默认为带有小数的全键盘的“数字侧”:

<input type="text" name="test" class="answers" id="mileage" value="0.0" maxlength=5 pattern="\d+(\.\d*)?"/>

Anyone have any ideas? 有人有想法么? Either to prevent Mobile Safari from correcting input number types (number types display the correct keyboard on iPods and iPads, but has built in correction on fields when the keyboard hides), or to force the keyboard to be on the Number side of the full iPod keyboard? 要么阻止Mobile Safari更正输入数字类型(数字类型在iPod和iPad上显示正确的键盘,但在键盘隐藏时在字段上内置校正),或者强制键盘在完整iPod的数字侧键盘?

FYI: This sounds very similar to my issue, however I may need a different solution. 仅供参考:这听起来与我的问题非常相似,但我可能需要一个不同的解决方案。 Sounds like they desired the "Full" numeric keyboard to appear by default but without number autoformatting that Safari does on the field when entering other characters in. 听起来他们希望默认情况下显示“完整”数字键盘,但是当输入其他字符时Safari没有自动编码。

Force a numeric keyboard but allow punctuation: HTML5, mobile Safari 强制使用数字键盘但允许使用标点符号:HTML5,移动版Safari

I know this is old but I see this being asked quite a lot. 我知道这已经老了,但我看到这个被问了很多。

To prevent validation of the number input type (and other types) you can use the novalidate attribute on the <form> element: 要阻止验证数字输入类型(和其他类型),可以使用<form>元素上的novalidate属性:

<form novalidate>
  <input type="number" name="test" class="answers" id="mileage" value="0.0" maxlength=5>
</form>

You'll still get the numeric keyboard but it won't force the user to enter numbers only. 您仍将获得数字键盘,但不会强制用户仅输入数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS5默认显示数字小键盘,不使用type =“number”或type =“tel” - iOS5 show numeric keypad by default without using type=“number” or type=“tel” Safari输入类型=“数字”无法显示实际值 - safari input type='number' can't display real value 输入类型号,十进制值 - Input type number, decimal value 在 ` 上禁用滚动<input type="number"> ` - Disable scrolling on `<input type=number>` 对于 input type=&quot;number&quot; 如何将默认值设置为 0 - for input type="number" how to set default value to 0 用角度指令在输入(类型=数字)中用逗号替换小键盘句号 - Replacing keypad period with comma in an input (type=number) with an angular directive 如何允许用户在小数点前输入一定数量的输入值,在小数点后键入一定数量的输入值 - How to allow user to type in certain number of input value before decimal and certain number of input value after decimal 如何限制和重置<input type="number" />与正则表达式反应? - How to restrict and RESET <input type="number" /> in react w/ Regex? 带Hammerjs滑动输入检测的输入类型范围在移动Safari中不可用 - input type range with hammerjs swipe detection not useable on mobile safari 从Mobile Safari日期输入返回的对象类型 - type of object returned from Mobile Safari date input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM