iPhone UIWebview: How to force a numeric keyboard? Is it possible?

Viewed 63595

I'm experimenting with PhoneGap to develop some iPhone apps. PhoneGap basically wraps a UIWebView - it works well. The problem is the my app has several input fields that only take numeric input. I really need to force the numeric keypad instead of accepting the default standard keyboard, which then forces the user to switch to the numeric on every field. Does anyone know if this is possible? How?

Clarification: I know that Apple doesn't currently provide any API to allow this. I'm wondering if creating a custom class that inherited from UIWebView might help, or maybe creating a custom keyboard would open up some possibilities?

Update 6 Nov, 2009 - As noted below, Apple has recently updated safari functionality so that this is, once again, supported. So the accepted answer was changed to reflect that.

 <html>
<input type='tel'/>
<input type='number'/>
<input type='email'/>
<input />
</html>
9 Answers

From Apple's documentation (the note about UIWebView):

You cannot specify the keyboard type in input elements. The web view displays a custom keyboard that is based on the default keyboard but includes some additional controls for navigating between form elements.

Checked on IPhone OS 3.0, this functionality was still not there, not sure why Apple just removed this handy functionality, really upset to work on this right now :(

This was possible in the first iteration of the iPhone OS - Safari would give numeric keyboards to form fields with 'zip' or 'phone' in their names - but it disappeared in iPhone OS 2.0.

PhoneGap doesn't have an API function to override this at the moment. It may be something they're working on, it'd definitely be a nifty feature.

Related