Is it possible to disable the 'next' and 'previous' buttons in Mobile Safari when focused on an input field? I've been trying the method of setting all fields to readonly="readonly"
and removing/reapplying the attribute on focus/blur respectively. It works for some fields, but not for all. In some cases, it feels rather hacky/buggy. Can I universally disable the previous and next controls? This is for an iPad web app, so accessibility is not an issue.
To access the settings menu, open the Safari app and on the menubar click on Safari > Preferences... (Fig. 1).
To change the tab layout in Safari on Mac, got to the Safari menu and select Preferences. Navigate to the Tabs section where you will find the Tab Layout setting. You can chose between Compact, which puts the tabs and address bar in a single row, or Separate, which puts the tabs below the address bar.
So far the best solution for me (based on Jezen Thomas solution) is to set on focus
readonly
to input
s and textarea
s and disabled
to select
s, and remove them on blur
:
jQuery('input, textarea, select').on('focus', function() {
jQuery('input, textarea').not(this).attr("readonly", "readonly");
jQuery('select').not(this).attr("disabled", "disabled");
});
jQuery('input, textarea, select').on('blur', function() {
jQuery('input, textarea').removeAttr("readonly");
jQuery('select').removeAttr("disabled");
});
Only one flaw is that you need to drop focus (for example clicking on background) before changing from input
/ textarea
to select. But you can easily change your focus between input
s and textarea
s.
I could see that this ticket is an old one, but the above proposed answer doesn't work for me as iPhone opens the select options list before the focus event is called. So I have used the below code and it worked like charm for me.
My working solution for this:
if (navigator.userAgent.toLowerCase().indexOf("iphone") ==-1) {
}else{
$(document).on('touchstart', 'input, select', function() {
$('select, input').not(this).attr('disabled', 'disabled');
}).on('blur', 'input, select', function() {
$('input, select').removeAttr('disabled');
});
}
This solution disables prev and next buttons in iPhone. If you want to change the selectors targeting only the specific input elements, you just need to modify it in the above code.
I'm targeting only iPhone (may be you can use different condition to test if it's iphone or not). Used 'touchstart' as it gets triggered before the 'focus'. On blur, I'm enabling the input & select fields back.
Hope this answer helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With