Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27616

Android: TextField with decimal keyboard type does not allow comma for decimal separator


    • Story Points:
    • Sprint:
      2020 Sprint 9, 2020 Sprint 10, 2020 Sprint 11, 2020 Sprint 12, 2020 Sprint 13, 2020 Sprint 14


      When using a TextField with "keyboardType" set to KEYBOARD_TYPE_DECIMAL_PAD or KEYBOARD_TYPE_NUMBERS_PUNCTUATION, the end-user is only allowed to enter a period '.' for the decimal point. It ignores the current locale and does not allow other types of decimal separators such as a comma ',' which is used Europe and South America.

      How to add languages on Android:

      1. Go to Android's main Settings screen.
      2. Tap on "System".
      3. Tap on "Language & Input".
      4. Tap on "Languages".
      5. Tap on "Add Language".
      6. Select a European language such as "German"/"Deutsch".
      7. Drag-and-drop the language to the top of the list.

      Steps to reproduce:

      1. Build and run the below code on Android.
      2. Select a European language. (See language instructions above.)
      3. Tap on the TextField.
      4. Attempt to enter 1,5 with a comma.
      5. Notice it won't let you use a comma ',' for the decimal separator.
      6. Enter 1.5 with a period.
      7. Notice that it allows a period, but this is not correct for the current locale.

      var window = Ti.UI.createWindow();
      	keyboardType: Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD,
      	width: "90%",

      This is actually a bug on Google's end. They have a partial fix for it as of Android 8.0 by using passing the current Locale to a DigitsKeyListener constructor.

      Unfortunately, Google's fix is incomplete and has the following issues:

      • Fullscreen edits (when in landscape) is not fixed. Only allows period for decimal point.
      • Does not support Arabic decimal separator at all.
      • Android OS versions older than 8.0 can't use their fix. We need a solution for Android 4.4 too.

      Original Post:
      In Denmark the decimal separator is comma (,)
      But when setting


      Titanium Shows a keyboard with a dot (.) instead...
      And when parsing a value with Danish Locale 20.50 becomes 2050
      On IOS the keyboard is shown with a comma (,) and everything works as expected


        1. keyPad.png
          12 kB
          Yordan Banev
        2. TextFieldKeyboardAdvancedTest.js
          8 kB
          Joshua Quick
        3. TextFieldKeyboardAdvancedTest1.png
          161 kB
          Joshua Quick
        4. TextFieldKeyboardAdvancedTest2.png
          187 kB
          Joshua Quick

          Issue Links



              • Assignee:
                jquick Joshua Quick
                thomas.neerup@eg.dk Thomas Neerup
                Gary Mathews
                Samir Mohammed
              • Watchers:
                8 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration