admin管理员组文章数量:1303327
I'm developing a React application that includes a form with an <input type="number"\>
. It works fine on most devices, but on Samsung tablets with the default keyboard, I can't enter a comma (,
) for decimal values.
Here’s my input code:
<input
type="number"
min="0.01"
className="textInputPVP"
value={producto.PVP}
onChange={(e) =>
actualizarProducto(producto.uniqueId, "PVP", + e.target.value)
}
onFocus={handleFocus}
/>
What happens?
The Samsung keyboard does not show the comma (
,
), making it impossible to enter decimal numbers in locales where the comma is the standard separator.It works fine on IOS and other keyboards.
What I tried:
Using
inputMode="decimal"
to force a numeric keyboard.Changing
type="number"
totype="text"
and validating the input manually.A significant changing like this:
<input
type="tel"
inputMode="decimal"
className="textInputPVP"
value={producto.PVP}
onChange={(e) =\> {
let value = e.target.value.replace(".", ",");
if (value === "" || isNaN(+value)) return;
actualizarProducto(producto.uniqueId, "PVP", +value);
}}
onFocus={handleFocus}
/\>
Solution I found:
After some testing, I realized the issue is specific to the Samsung default keyboard. Simply installing and using Gboard solves the problem immediately without any code changes.
I'm developing a React application that includes a form with an <input type="number"\>
. It works fine on most devices, but on Samsung tablets with the default keyboard, I can't enter a comma (,
) for decimal values.
Here’s my input code:
<input
type="number"
min="0.01"
className="textInputPVP"
value={producto.PVP}
onChange={(e) =>
actualizarProducto(producto.uniqueId, "PVP", + e.target.value)
}
onFocus={handleFocus}
/>
What happens?
The Samsung keyboard does not show the comma (
,
), making it impossible to enter decimal numbers in locales where the comma is the standard separator.It works fine on IOS and other keyboards.
What I tried:
Using
inputMode="decimal"
to force a numeric keyboard.Changing
type="number"
totype="text"
and validating the input manually.A significant changing like this:
<input
type="tel"
inputMode="decimal"
className="textInputPVP"
value={producto.PVP}
onChange={(e) =\> {
let value = e.target.value.replace(".", ",");
if (value === "" || isNaN(+value)) return;
actualizarProducto(producto.uniqueId, "PVP", +value);
}}
onFocus={handleFocus}
/\>
Solution I found:
After some testing, I realized the issue is specific to the Samsung default keyboard. Simply installing and using Gboard solves the problem immediately without any code changes.
Share Improve this question asked Feb 10 at 10:24 Joan Jorda MoltoJoan Jorda Molto 11 bronze badge2 Answers
Reset to default 0Quickest fix: probably try directly HTML lang attribute: what is the role of the locale? (but only temporal and try it well on other devices, while you implement a long run fix).
And for the long run...
I think that for solving this kind of issue and many others you should:
- offer a configuration screen which on some section allow users to enable various options for fixing this kind of issues,
- or even better, try to detect the issue automatically and show a floating mini dialog sugesting the user to enable the fix. Both if you detect the problem via user-agent signature or thru user's strange behaviour. I'd show always 3 options on these floatings: a. enable fix b. contact for feedback and c. close this dialog.
- implement the fix itself: can be the simply HTML lang attribute: what is the role of the locale? thing or maybe something more radical like downgrading all numeric inputs into text inputs (maybe with character restriction into them).
About previous answer: requiring the users to install an 3rd party app, even being from google is probably a very bad idea, even if they are only less than a hundred): can be very problematic, time consuming and even potential legal problems issue... you know if you talk to near any client service department anytime soon.
The issue comes from the Samsung default keyboard, which disables the comma (,
) in <input type="number">
.
✅ Quickest Solution: Simply install and use Gboard instead of the Samsung keyboard. This fixes the issue immediately.
本文标签: htmlCan39t type a commain ltinput typequotnumberquotgt on Samsung tabletsStack Overflow
版权声明:本文标题:html - Can't type a comma , in <input type="number"> on Samsung tablets - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741720984a2394387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论