Samsung Galaxy Tablet does not allow entering floating point numbers to inputs with "number" type
Asked Answered
G

5

15

Our client wants us to display numeric keyboard for an input field so basically I created a field like:

<input type="number" name="quantity" step=".01" value="0.00" />

However, Galaxy Tablet erases "." and merges numbers before and after it, also disables "." in the keyboard.

Is there another way to solve this issue or display numeric keyboard in input field when using type="text"?

Note: I tried using pattern attribute (which works on iPhone). I tested this issue on various Android devices with Android 2.1+. I did not encounter this error on any other HTC and Samsung devices.

Gusher answered 21/6, 2012 at 9:6 Comment(7)
is by any chance your tablet set to european number format? - decimal point and comma are inversely used in european number formatCreolized
unfortunately no, I am testing on US keyboard and also client tests in Australia.Gusher
Which Galaxy-tab and which version of android?Nairn
@PrashantGupta I'm having the issue on Galaxy Tab GT-P7510 (10 inch) on Android 3.2Bebe
It works on my Galaxy Tab 10.1 (PT-7510), although I was never graced with an update to 3.2. At least we can rule out it being an issue on Android 3.1.Evetteevey
Set property of your Edittext or text box from your layout xml fileEke
@Eke This is not related to Android SDK or Android Layouts. This is about HTML5 input types in an Android browser or WebView.Bebe
T
7

Yes, there is another way.

  1. Way 1: don't use type="number" but use type="text"
  2. Way 2: Apply way 1 for only Android phones. Detect User-Agent etc.
  3. Way 3: Apply way 1 for only broken implementations. See: What models of Samsung smartphones have missing period for html5 input type="number"?
  4. Way 4: Use type="tel"' for only Android or broken. (can't use on iPhone as no period then)
  5. Way 5: use type="text" and then javascript with custom behavior. See:

Period always shows: http://jsbin.com/heqeduyi/1/

Period shows once 3 digits: http://jsbin.com/yinaweho/1

Tobias answered 30/4, 2014 at 13:17 Comment(1)
Would the following work? <input inputmode="decimal" type="text" />.Reiners
D
3

A workaround is to use type="tel" instead of type="number". Unfortunately on iOS type="tel" doesn't display the , char on the keyboard (at least I didn't find it there). You can check the user agent for iOS devices and then change type on "number".

Damico answered 26/7, 2012 at 8:36 Comment(0)
B
1

Did you try setting step to "any". Like:

<input type="number" name="quantity" step="any" />

I took out the "value" because I think you should, even if just for testing

Brachium answered 6/11, 2012 at 0:35 Comment(0)
I
1

I do this in C#/Xamarin and what works for me on the code side (I dynamically build up forms) is using the following:

   EditText edittext1 = new EditText(view.Context);
   edittext1.InputType = Android.Text.InputTypes.NumberFlagDecimal;

Hope it helps someone

Ivanna answered 8/6, 2016 at 6:40 Comment(0)
A
-1

To have decimal point in the numeric keyboard on Android Samsung devices use this in you EditText:

 android:inputType="numberDecimal"
Appleton answered 13/5, 2014 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.