简体   繁体   English

将键盘隐藏在手机/平板电脑的文本字段中

[英]Hiding keyboard on a text field in mobile/tablets

I have a text field which uses bootstrap datepicker plugin. 我有一个使用Bootstrap Datepicker插件的文本字段。 Text field is as below- 文本字段如下-

<input id="Date" name="Date" type="text" value="">

JS code that binds datepicker with it is as follows- 绑定datepicker的JS代码如下-

 $('#Date').datepicker({
        format: "dd MM, yyyy",
        disableTouchKeyboard: true,
        todayHighlight: true
    });

In desktops, it works fine. 在台式机上,它可以正常工作。

I have problem in mobiles and tablets - When user click on this textbox, it shows calendar as well as virtual keyboard. 我在手机和平​​板电脑上遇到问题-用户单击此文本框时,它会显示日历以及虚拟键盘。

I want to hide virtual keyboard for this textfield for mobile and tablets whenever it gets forcus. 我想在手机和平​​板电脑遇到问题时为该文本字段隐藏虚拟键盘。

How can I do that? 我怎样才能做到这一点?

i was getting the same issue once before and i solved it by typing 我以前也遇到过同样的问题,我通过输入来解决

$('#Datet').blur();

just in other case it will not help you tro to use so this is a pure JS code to handle it 在其他情况下,它不会帮助您使用,因此这是处理它的纯JS代码

document.activeElement.blur();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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