Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Mauchline, Scotland
    Thanked 1 Time in 1 Post

    force the focus to leave a form field with jQuery in iOS

    Using jQuery or something similar, is it possible to detect when a user has clicked away, effectively removed focus, from a form field in iOS? I have conventional form which has a first name, last name, address line 1, address line 2 etc.

    On an iPad when you select a form field the only way to leave that form field is to select another field in the form by clicking it or by hitting the Previous or Next buttons in the keyboard pane.

    As the keyboard pane is shown clicks to other non-input elements on the page are ignored, so focus remains on the form field.

    Is there a way with jQuery/JavaScript (or anything else) to force the focus to leave the form field if I click away from it by clicking a non-input form element?

    I have tried this sort of thing, but to no avail. Is this likely to be locked down by Apple's iOS?

    $('body').on('click', function () { $('form').blur(); });
    Here's an example of what I mean. In the screen below, when the focus is on the Line 1 element I can't move out of it by clicking a non-input element.

  2. #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Jakarta, Indonesia.
    Thanked 78 Times in 76 Posts
    Untested, but maybe you should install that to another CLICKABLE(?) element e.g. a link, an input, etc rather than the body.
    $('#dummy').on('click', function (e) { 
    <a id="dummy" href="#">&nbsp;</a>
    Last edited by hdewantara; 09-27-2012 at 01:41 PM.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts