Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Numeric with decimals on mobile

Lighthouse 9.5.3 uses type="tel" for numeric fields in order to get a numeric keypad. Unfortunately on iOS there is no possibility to enter a dot or a comma as a decimal separator. With so many users doing surveys on iPhones today this behaviour should be changed.
Any ideas would be appreciated.
asked Mar 6, 2018 by ingo Bronze (710 points)
retagged Mar 6, 2018 by Walter Williams

1 Answer

0 votes
Operating systems have control over which keyboards they open for each input type.  I have written some code that changes the types used by inputs on a page.  Adding this to your question may resolve your situation:

    $('input[type=tel]').prop('type', 'number');

Hopefully type=number will be sufficient for you.  If not, type=text is always an option that should open the full keyboards.
answered Mar 7, 2018 by Zachary Platinum Sawtooth Software, Inc. (205,575 points)
Hi Zachary, type=number will not work because it is not possible to enter the comma as a decimal separator. I will have to use type=text. It's a pity that then on all mobile devices the normal keypad will open. On Android the behaviour was perfect before...
Is there a possibility to change to input type only for iOS?
I'm sorry to hear type=number has not worked out.  Modern browsers do not typically definitively state the user's OS, but this can be worked around if necessary with some user agent testing.  Try this:

    if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
        $('input[type=tel]').prop('type', 'text');
Thank you very much, Zachary. This seems to work. Maybe you could consider this solution for the next version of Lighthouse. Addionally it is a little bit strange for the user that for "system" numeric fields type=tel ist used, but for free format numeric fields type=text.
User agents are infamously fickle.  The code I gave you may work now, but there is no guarantee it won't need to be modified the next time Apple releases an update.  This is why I'm a bit hesitant about including code like this built into the software; we can't release an update to Lighthouse Studio every time an OS releases an update to keep all user agents up to date.

I do agree that numerics in free formats defaulting to type=text seems strange.  That should be looked into on my end.
Thank you again. I would recommend that you keep in mind for further versions that it has to be possible to enter decimals in numeric fields even on iPhones. For me the current behaviour is a clear bug of Lighthouse Studio.
numeric questions with decimals