2

We have a mobile forward data entry page that has an input:

<input type="text" id="result" ...>

Edit: I would like to strike through and/or omit this comment: "What I would like to do is default to the alphanumeric keyboard which is on the second level on my Android device (and I assume on other devices) where you have the numbers running across the top. Right now the above defaults to the alpha keys."

And replace with: What I would like to do is default to the mobile numeric keypad as a default but still allow a user to enter an occasional text entry.

I've tried using text="number" and text="tel" but that doesn't meet the requirement because although the typical entry is going to be something like "7.5" (thus the desire to default to the numeric keys) there will be cases where the user enters "pass" or "ok" or some other bit of text and I don't see a way to use "tel" or "number" and allow for the entry of text as well.

Edit:

My solution:

I found an elegant "workaround" for this. I simply added a checkbox to the form:

<label>
    <input id="cbAllowTextResults" type="checkbox" value="">Allow entry of text results.</label>

And added a click handler to the checkbox that toggles the type between text and number based on whether the checkbox above is checked:

if ($("#cbAllowTextResults").is(":checked"))
    $("#inputSresult").attr("type", "text");
else
    $("#inputSresult").attr("type", "number");

This will allow and end user to toggle between text and number keyboard.

Jeff Mergler
  • 1,384
  • 20
  • 27
  • There is no requirement on Android for any device to even *have* a keyboard that has "numbers running across the top", let alone a way to demand it from HTML. Please understand that there are thousands of Android device models, which ship with dozens or hundreds of stock soft keyboards, in addition to ones that users install from the Play Store or elsewhere. – CommonsWare Jun 13 '16 at 20:43
  • 2
    Understand. Thanks for finding the duplicate and shaking me back to my senses. This made me rethink the requirement from a fresh perspective and I adapted my UI rather than looking for a feature that in retrospect was far fetched and unrealistic. – Jeff Mergler Jun 13 '16 at 22:01
  • @jeffreymergler Your response to feedback is refreshing, and I like the solution that you came up with. You might consider modifying your question slightly, so that your workaround could be posted as an answer. If you can reword it so that the question is not a duplicate, it could be re-opened. – Michael Gaskill Jun 13 '16 at 22:15
  • 1
    Sure! I wasn't aware that rewording it was an acceptable way of doing things. I will give it a try. – Jeff Mergler Jun 13 '16 at 22:24

0 Answers0