4

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"/>
Chintan Khetiya
  • 15,208
  • 9
  • 41
  • 81
faoc
  • 125
  • 2
  • 9

5 Answers5

5

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

blong824
  • 3,590
  • 13
  • 48
  • 72
4

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

$('#datepicker').focus(function() {
  this.blur();
});
ceejayoz
  • 165,698
  • 38
  • 268
  • 341
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
});
VoVaVc
  • 673
  • 1
  • 10
  • 29
1

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

Søren Lorentzen
  • 810
  • 1
  • 11
  • 26
1

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.

David Reinberger
  • 540
  • 3
  • 11