7

I am working on a hybrid apps where I need to display numeric keyboard with dot and comma for iOS. I tried the pattern [0-9] with type as number. It works for android but does not show dot/comma for iOS. Anyone has any idea how to achieve this for iOS ? i tried searching for cordova plugin. Did not get any. I created a custom keyboard in angular. But it is having some delay for iOS when i provide any input. I need below attached keyboard in html5 input field. For ios i don't get dots using "input type="number" min="0" inputmode="numeric" pattern="[0-9]*"".

Please see attached screenshot

Bhaskar Hazarika
  • 71
  • 1
  • 1
  • 4

3 Answers3

14

2019 Update

For anyone coming from Google looking for a working solution, this is now possible with the inputmode attribute as of iOS 12.3.

So something like <input type="number" pattern="[0-9]*" inputmode="decimal"> will show the numeric keyboard with a dot/comma for Android/iOS 12.3+, and the regular numeric keyboard for older iOS devices - note that inputmode has to be set to "decimal".

More info available on MDN.

Rem Zhang
  • 149
  • 2
  • 8
1

its will works Android and iOS

  <input type="number" pattern="[0-9]*" inputmode="numeric">
Nazır Dogan
  • 1,494
  • 15
  • 31
  • 1
    I tried with this . In android it works fine. But in ios i am not getting comma and dots. Mine is currency field . So I need to have both this chars. Thanks for the reply. – Bhaskar Hazarika May 18 '16 at 08:01
  • if you want keyboard with comma and dots just use – Nazır Dogan May 18 '16 at 10:18
  • iOS numeric keyboard look like this. Platforms can have diversity. I think Android and iOS works different for keyboard. http://www.globalnerdy.com/wordpress/wp-content/uploads/2013/02/twitter-2.png – Nazır Dogan May 18 '16 at 10:21
  • Using number i gets other special chars which I don't want. I want a simple keyboard with 0-9 ,dot and backspace. I can use number and restrict users to enter any chars other than i mentioned. But that I want to be my last option. – Bhaskar Hazarika May 18 '16 at 17:29
0

You can use something like,

<input type="number" pattern="[0-9]*" inputmode="numeric">

Update :

You can do something like,

 EditText myEditText = (EditText)findViewById(R.id.myEditText);
 myEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

Or:

 <input type="tel" />

or

 <input type="number" step="0.01">

You can refer this stackoverflow question.

Hope this will help :)

Community
  • 1
  • 1
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • 1
    I tried with this . In android it works fine. But in ios i am not getting comma and dots. Mine is currency field . So I need to have both this chars. Thanks for the reply. – Bhaskar Hazarika May 18 '16 at 08:02