I'm trying to create a simple app that will be mostly used on mobile devices (primarily iOS). The number inputs have the type="text" instead of type="number". If my understanding is correct, Android devices will display the number pad style keyboard when the inputmode="numeric" (which they are already listed as numeric), but this is not true for iOS devices.
How do I change the type to equal number, or add in a pattern attribute like pattern="[0-9]*"?
With the standard-issue keyboard coming up, the number inputs are clunky and not very user-friendly.
Thanks in advance for your help,
Hello! Thanks for writing in. Are you making a form or using some type of component that has a different input than expected? Could you share a screenshot of your app and the setup? Especially anywhere that has the
type= like you mentioned above. Thank you!
Just wanted to follow up and see if you could share a little bit more about your app. Any screenshots of where the input types are giving you trouble would be a great help!
Thank you for your patience and checking in. The app that I'm working with is a simple form for checking and changing inventory status. I'm using a stock number input component to capture the SKU that the user is checking or changing the status of. On a mobile device, having the standard qwerty keyboard activate upon focusing on this input is cumbersome. Having the number pad keyboard activate would be much more user friendly.
This is what I'm seeing when inspecting the element:
<input id="SKU--0" autocomplete="off" placeholder="Enter value" inputmode="numeric" aria-roledescription="Number field" autocorrect="off" spellcheck="false" class="_vrlvt _2gurE" type="text" value="0">
My understanding is that if the
type="text" is changed to
type="number" the number pad keyboard will be activated. This is generally not a desirable default setting as the number pad keyboard does not provide a decimal, dash, or the ability to navigate to a normal keyboard. For this use case, however, the only input will always be numeric digits 0-9. Adding in a pattern attribute would also be helpful for having this format properly.
This script is executing as indicated by the note being seen in the log, but the attributes are not being applied.
I am attaching a screenshot of the app on a iOS mobile device. The number input that is in question is the one labeled MEMS#.
Thank you in advance for your help,
So, I've done some fiddling with this and I'm seeing some interesting behavior. I've tried three different configurations in JSFiddle to see what would happen – https://jsfiddle.net/5gj3erob/4/
Number input with
Number input with
inputmode="numeric" – this is the default for the Retool App that I've already tested.
Number input with
In #1 and #2, I have
type="text" which is the default attribute. When the
inputmode are not specified, they are omitted.
#1 and #2 behave as expected and as desired. #3 does not display the number pad keyboard, but instead the standard keyboard with the number section visible. I find this interesting, because with the code directly copied from Retool App that I've been testing, the desired number pad keyboard is activated on the JSFiddle, but when running the Retool page, it doesn't.
Are you aware of anything that might be keeping this from activating? Is there anything within the Retool backbone that was intentionally added to prevent the different keyboards from activating?
Any luck looking into this at all? I still haven't been able to figure this out on my end.
I've been looking into this a bit and haven't had much luck so far. It looks like the input brings up the numpad properly when used in a custom component, might that be helpful?
Thanks for the reply. I appreciate the suggestion. I was able to find the custom component tutorial in the docs, but I'm not experienced with React.js. I'll try to go through the tutorial and see what I can manage to setup. I'll post an update when I get the chance.