Autofocus text field on mobile, but no keyboard?

Niet the Dark Absol picture Niet the Dark Absol · May 18, 2014 · Viewed 11.7k times · Source

As part of my login and registration forms, if there are errors then it will autofocus the related field. Actually, it not as simple as I thought. Let me try to explain!

Basically, on this project, pages are loaded with AJAX. Forms may include an autofocus attribute. This works great, but on mobile it just shows the cursor without bringing up the keyboard, meaning you still have to tap the input to start typing.

Am I missing something, or do I have to double-up the focussing with something like

document.querySelector("[autofocus]").focus();
// with appropriate verification that the element exists, of coursr

Answer

Tarun picture Tarun · May 18, 2014

In mobile devices (at least in Apple's Safari), the keyboard isn't allowed to show up without the user clicking on the input field. It's by design, and I don't think there is much you can do about it.

http://www.quora.com/Mobile-Safari-iPhone-or-iPad-with-Javascript-how-can-I-launch-the-on-screen-keyboard