/    Sign up×
Community /Pin to ProfileBookmark

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?

[CODE]$(‘body’).on(‘click’, function () { $(‘form’).blur(); });[/CODE]

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.

[ATTACH]15045[/ATTACH]

[canned-message]attachments-removed-during-migration[/canned-message]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meSep 30.2012 — yes, it's very doable.

blur() the focused input, not the form.
×

Success!

Help @crmpicco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...