0

Part of my app has a form in WebView? How can I detect if the user is clicking on something in the html that should be numeric only? For example a zip code or credit card info? That way I could present them with the correct type of keyboard?

Code Droid
  • 10,344
  • 17
  • 72
  • 112
  • I'm used to SO posts without question marks, this style is new to me though? ;) –  Sep 06 '12 at 21:28
  • I see where you are from. I didn't think you're into questioning marks :) – Code Droid Sep 07 '12 at 01:20
  • Oh I don't mind them, I just found it funny that you don't know what features your app has ("Part of my app has a form in WebView?"). –  Sep 07 '12 at 09:58

1 Answers1

1

Basically you are trying to fix a missing implementation of HTML5 in android devices: http://www.quirksmode.org/html5/inputs_mobile.html

this should give you a hint on how to call Java native functions from JS http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface%28java.lang.Object,%20java.lang.String%29

I don't think you can progrematically change the keyboard input method when it's displayed.

This is one way to open the keyboard, but you'll need to handle the input and this will look bad as you won't see where you are typing. Open soft keyboard programmatically

anoother way solve the issue of the keyboard type I would popup a native dialog with a textfield and set the keyboard type of this field to the one you need.

then send the result back to the webview by injecting javascript using loadURL();

at anycase you'll want to set the html field to readonly so it's keyboard doesn't jump.

Community
  • 1
  • 1
Raanan
  • 4,777
  • 27
  • 47