Search code examples
htmltwitter-bootstrap-3bootstrap-select

Changing Bootstrap select's live search input type


I am using Bootstrap Select with the live search on.

My select however contains only a list of years. As a consequence, on a mobile device, I'd like the numeric keyboard to pop-up, not the full text. This is theoretically easy to do: change the type of the input to tel and you're done!

However, I see no way in Bootstrap Select's documentation or issues to do this. Do you know of any way to achieve this?


2016-09-01: I opened a feature request on Bootstrap Select's Github


Solution

  • You could try it with altering the search inputs type after the select has been loaded by listening to the bootstrap-selects events with something like this:

    $('#mySelect').on('loaded.bs.select', function () {
        $(this).closest('.bootstrap-select').find('.bs-searchbox input').attr('type', 'tel')
    });