all articles

android readonly input can still be focused

2015-08-06 @sunderls

android readonly input focus js

description, bug

if we set input to readonly, the input should be unfocusable, which means when clicked, the keyboard should not comes out.

while this works as expected in iOS,on some Android devices readonly input can stilled be focused.

how to stop keyboard

since readonly is not working, we can stop using input, replace it with <div>.

But I don't like this one, rather I'd like to use disabled, as following:


if (shouldNotShowKeyboardWhenClicked && isMobileBrowser){
     $input.prop('disabled', true);

// add the listener to the parent, since `disabled` input triggers no event

$input.parent().on('click', function(){
    // handle the click