JQuery Mobile Force hides soft keyboard when focusing text input field

I have a date field on a PHP website and I'm using jQuery Mobile for a mobile site.

When viewing the site in a mobile browser (for example, firefox mobile on android), when I click on the date text entry, the calendar dialog opens, but the soft keyboard also appears on my android (the soft keyboard appears every time one focuses on the input field) Is there a way I Can I make a soft keyboard hide? Is there a general javascript-based trick to make hiding a soft keyboard (which works on all mobile devices like iphone, android, etc.

I am using jQuery Mobile datepicker from here tia

+6
source share
4 answers

Just found the answer to my question. (I guess I haven't looked for the right keywords before: - |)

Adding a jQuery blur event in focus solves the problem.

Thanks to this post by Danny C

+4
source

A simpler solution is to add readonly = "true" to the input fields to which you are bound by datepicker. Even if you cannot manually enter the date, on the mobile phone you do not have to deal with a keyboard that appears and interferes

+6
source

My workaround (although I'm using another plugin: date-date from jtsage.com) currently looks like this:

  • set disabled attribute on input
  • bind the click handler to the input or its parent element
  • click handler launches .datebox ('open') for the selected item

Thus, there is no focus element, so there is no launch of the Android soft keyboard.

0
source

add the readonly attribute in the date field. (or readonly = "readonly") input type = "text" data-role = "date" readonly

For JQM, add the following files jqm.datepicker.css, jqm.datepicker.theme.css, jqueryUI.js, jqm.datepicker.js

0
source

Source: https://habr.com/ru/post/900556/


All Articles