How to hide keyboard on phonegap android

10,122

Solution 1

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

Solution 2

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

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

Solution 3

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

use it like that:

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

Solution 4

Alternatively you could use the new HTML5 input types.

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

in Google Chrome i get the following:

'Date' HTML5 input type

Solution 5

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.

Share:
10,122
faoc
Author by

faoc

Updated on June 15, 2022

Comments

  • faoc
    faoc almost 2 years

    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. how can I disable the keyboard?

    Code as below :

    <label> Date: </label> <input id="datepicker" type"text" name="date"/>
    
  • Yoh Suzuki
    Yoh Suzuki over 12 years
    This works if the keyboard is not already visible. If it's already shown, do you know a way to hide it?
  • Neromancer
    Neromancer over 11 years
    Great thinking! Solved my problem completely.
  • Neromancer
    Neromancer over 11 years
    BTW... My problem was in Phonegap/Cordova trying to stop the keyboard poping up before the datepicker (using the datepicker plugin).
  • Dilawar
    Dilawar about 5 years
    Link is broken.
  • VoVaVc
    VoVaVc over 2 years
    Fixed the link.