Change input type value if is mobile device
<p>Guys I'm using jquery UI library for date picking and time picker addon. 
All work on PC but I want to change <code>input type</code> from <code>text</code> to <code>date</code> or <code>time</code>.</p>

<p>When I test on mobile device I want mobile to use default datetime picker(scroller). </p>

<p>By default I just use simple code for showing dialogs</p>

<pre><code>$('.datepicker').datepicker();
$('.timepicker').timepicker();
</code></pre>

<p>So is it possible to check if it is a mobile device? If yes change type to date or time.</p>

<p>I try to create function which will detect if a user connect with mobile device but it doesn't work</p>

<pre><code>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
      var date = document.getElementById('datepicker');
      date.setAttribute('type','date');
}
</code></pre>

<p>But this function work when I check if it is mobile</p>

<pre><code>function isMobile() { return ('ontouchstart' in document.documentElement); }
</code></pre>

<p><strong>Here is full working code:</strong></p>

<pre><code>&lt;script&gt;
    (function() {
        var date = $(".datepicker");
        var time = $(".timepicker");
        var isTouchDevice = 'ontouchstart' in document.documentElement;

         if ( isTouchDevice ) {
             date.attr("type", "date");
             time.attr("type", "time");

        } else {
             date.attr("type", "text");
             $('.datepicker').datepicker();
             $('.timepicker').timepicker();
        }

    })();

&lt;/script&gt;
</code></pre>