How to run custom datapikers from javascript in FirefoxOS?

I want to open my own datepicker FirefoxOS with the click of a button. By default, the native feedback indicator appears when there is focus at the input (date type explicitly). But how to do it for a button? Moreover, I do not like the data on the input date, because my application is in French, and the format of the date displayed in the date input is not French.

I tested using date input hidden by css. Clicking on the button brings up focus on the input. But in this case, the date picker is not displayed.

Please do not suggest me using jQuery UI or other javascript datepickers. On a mobile phone, they are not very convenient, and the best are native datapikers.

thanks for the help

+4
source share
1 answer

Firstly, if you ask a question about how to use the button to start your own date selection, you can do this by calling focus on it, for example:

<input id="datepicker" type="date"> <button onclick="document.getElementById('datepicker').focus()"></button> 

If it hides the date picker, but still uses it with a button, you can put the opacity at 0 with CSS, but it will still be there, just not visible:

 #datepicker { opacity: 0; } 

Does this answer your question?

+6
source

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


All Articles