0

I am writing a web interface for mobile devices. And I want to restrict input in the textarea: numbers 0-9, space, enter. I would like to see the default numeric keypad for textarea. But for textarea by default standard keyboard is showing. If I use virtual keyboard (simple buttons and javascript) standard keyboard still shows. How to disable the standard keyboard for textarea or set default numeric keypad?

Andy
  • 263
  • 2
  • 5
  • 16

5 Answers5

3

You can use the global attribute inputmode in textarea. This will open the numeric keyboard in Android and iPhone. Other keyboard variations are available such as tel (phone pad), email, and url.

<textarea inputmode="numeric">
</textarea>

See the MDN docs on inputmode for more.

Coder-256
  • 5,212
  • 2
  • 23
  • 51
Adam Combs
  • 31
  • 4
-1
setRawInputType(InputType.TYPE_CLASS_NUMBER);
DevlshOne
  • 8,357
  • 1
  • 29
  • 37
-1

You must set the Input Type to "number". The number type is used for input fields that should contain a numeric value. You can also set restrictions on what numbers are accepted.

Example: Define a numeric field (with restrictions): Quantity (between 1 and 5):

<input type="number" name="quantity" min="1" max="5">

Use the following attributes to specify restrictions:

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value
Manuel Taber
  • 427
  • 5
  • 19
  • If you use a virtual keyboard you can use preventDefault() on the textarea to prevent opening the default keyboard – Manuel Taber Nov 26 '13 at 13:08
  • I try use code: $(textarea_id).insertAtCaret(txt); event.preventDefault(); but standard keyboard is showing – Andy Nov 26 '13 at 13:21
-1
<EditText
    android:id="@+id/launch_codes"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/enter_launch_codes"
    android:inputType="number"
    android:imeActionLabel="@string/launch" />

use the input type number in order to see the default numeric keypad

Rajesh Vishnani
  • 95
  • 1
  • 2
  • 20
-2

Use the android:inputType option.

In the xml layout file, you can define your textarea like this :

<EditText
    android:id=yourID
    android:inputType="phone" >
</EditText>
eduine
  • 147
  • 2
  • 12