[英]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.