简体   繁体   中英

In Android web browser dismiss keyboard on html input element focus

Here what I have: - I load html page on Android Browser; - when I choose SELECT DATE the input element with a type="text" gets focus and using jQuery loads the a date picker; - but as a side effect of getting focus I get Android keyboard shown;

How can I dismiss the keyboard but at the same keeping focus on this input element with a type="text"?

There are some requirements: 1) there logic has to be configured in html page (I mean not on Android device, but of html, js or css); 2) input field can't be hidden, disabled or taken away (it will take away date picker);

在此处输入图片说明

I think I found the short and sharp solution:

  • add to this input element new attribute: readonly="readonly" so finally my input element will look like:

    < input type="text" id="datepicker" readonly="readonly" ... >

it will show jQuery date picker and at the same time it will not trigger Android device keyboard to show;

Hope it will be helpful for somebody else.

Try this!

Add onfocus="blur();" in text field.

For example,

<input type="text" name="exapmle" onfocus="blur();">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM