24

Is there any setting using which the iPhone keyboard won't appear for a particular textbox in web page? May be some css kind of setting?

1
  • Sorry for closing this. Despite being much older, the newer (2011) question has attracted better quality answers. Jun 2, 2016 at 14:07

5 Answers 5

47

you just make the input field as readonly="true"/ readonly mode so that keyboard wont appear!!

2
  • 5
    I just tried this, it worked for me! I'm using the jqueryui datepicker and didn't want the keyboard to pop up. This did the trick.
    – Ben Noland
    Sep 26, 2009 at 17:24
  • 4
    this will not show cursor, and users wont be able to see where they are. any solutions for that?
    – Nazerke
    Jun 20, 2014 at 5:50
3

Do you want the text box to be editable for any other browser other than the iPhone? If not, have you attempted to disable the text box? I haven't tried this, nor can I recall seeing a disabled text box on a site with my iPhone; however, it may do it.

If disabling the text box works, but you still only want to restrict it to the iPhone, you'll need to look at the User Agent for the iPhone. You can determine this through server side code or through JavaScript's navigator.userAgent.

To save a bit more time for you as well, the iPhone's user agent is as follows:

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3
3

Keep in mind that readonly="true" isn't required.

<input type="text" readonly> is enough.

1

If you want hide keyboard for iphone/ipad/ipod users you must identify this useragents. I recomend http://wurfl.sourceforge.net/ to find different versions of these devices and then printing readonly="true" disabled="disabled" on inputs.

0
0

I don't think you'll be able to truly disable the keyboard just like you cannot truly disable the keyboard when you browse a webpage via a PC or Mac. One trick would be to add JavaScript to intercept the OnKeyPress (or OnKeyDown) event to intercept the key stroke and cancel it based on the User Agent. I haven't tried it against the iPhone specifically but it has worked for other applications when I want to restrict the type of input on an enabled text box (i.e. canceling alpha characters in a phone number field). Since the "OnKey" events are still valid on the iPhone (as determined by sites with autocomplete like Google), the method should work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.