开发者

How to hide keyboard on phonegap android

开发者 https://www.devze.com 2023-03-28 07:11 出处:网络
I am using 1.0 PhoneGap for android. I have an application form with several fields, one of them is to put the anniversary. I put a datepicker that field, yet when you click on the field, the keyboard

I am using 1.0 PhoneGap for android. I have an application form with several fields, one of them is to put the anniversary. I put a datepicker that field, yet when you click on the field, the keyboard appears. ho开发者_如何学JAVAw can I disable the keyboard?

Code as below :

<label> Date: </label> <input id="datepicker" type"text" name="date"/>


You can mark the input field as read only and then create a function for an onclick event to display the datepicker.


Not sure what JS library you're using, but in jQuery, you'd do:

$('#datepicker').focus(function() {
  this.blur();
});


If you need to hide keyboard on android you can use this plugin

use it like that:

plugins.SoftKeyBoard.hide(function () {
    // success
},function () {
   // fail
});


Alternatively you could use the new HTML5 input types.

<input type="date" name="bday" />

in Google Chrome i get the following:

How to hide keyboard on phonegap android


This worked for me and saved my head from excessive scratching!

var hideKeyboard = function() {
    document.activeElement.blur();
    $("input").blur();
};

The solution was found here, where you can find a non jQuery solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号