The default keyboard
You have probably seen this keyboard before: the default iOS keyboard that pops up for <input type=”tel”> form fields.
I don’t want those buttons!
The numeric keys are just fine, but the Previous/Next/Done buttons are not what I want when showing a page with only one input field. So… I wondered if the navigational buttons could be removed in my PhoneGap / Cordova HTML5 app.
A solution 🙂
Fortunately, the internet is full of people who have similar problems, so a quick look around the globe revealed this great post.
UPDATE July 2013: simply adding this to your config.xml may get the trick done as well. BEWARE: it’s an app-wide setting, so if you need more fine grain control, read on. <preference name=”HideKeyboardFormAccessoryBar” value=”true”/>
But wait, there’s more!
This blog entry wouldn’t have existed if that was it. What I actually wanted, was an on demand solution; for one page show the buttonbar, and hide it on other pages.
Conditionally show or hide the navbar
What I wanted was controlling the appearance of the navigation bar based on a tag in the HTML. A custom class for the body tag seemed right, so I added this to the page for which the navigation bar should be hidden:
So all I had to do was adjusting the piece of obj-c I added to my PhoneGap wrapper by checking for existence of the aforementioned classname:
The added code is on the highlighted lines: simply check whether or not the className of the body is equal to the className we hide the navigation bar for.
Question for the reader
I’m afraid the trick in the blogpost is as far as we can stretch the boundaries of the HTML keyboard on iOS devices. But… if anyone knows how to add a comma in the empty field below the 7, you’d be king.