The problem I'm having is .focus() doesn't pull up the mobile datepicker, as my input type is 'date'.
Therefore I tried to have trigger('click tap') on the input box and that doesn't work either.
To reiterate, on my desktop it works fine, the box gets focused, but on a phone (mobile safari) the box is focuses BUT no datepicker shows up. This datepicker/spinner is the default html5 in mobile browsers, AFAIK.
<form id="mobileAgeGate" onsubmit="return false;">
<input id="mobileDate" type="text" onfocus="this.type='date'" onblur="this.type='text'" name="date" min="1900-01-01" class="date-mobile" placeholder="mm/dd/yyyy" pattern="(?:0?2[/.-](?:[12][0-9]|0?[1-9])|(?:0?[469]|11)[/.-](?:30|[12][0-9]|0?[1-9])|(?:0?[13578]|1[02])[/.-](?:3[01]|[12][0-9]|0?[1-9]))[/.-][0-9]{4}">
</form>
And the js, inside the document ready as normal:
if ($('#mobileDate').length) {
setTimeout(function() {
// $('#mobileDate').focus(); // This one works (but no mobile spinner pops up)
// $('input[name="date"]').focus(); // This one works (but no mobile spinner pops up)
$('#mobileDate').css('background-color', 'gray'); // to test something is indeed happening; ok
$('input[name="date"]').trigger('click tap mouseover'); // This doesn't even focus
}, 3000);
}
The timer isn't really important to the question, but it's there to wait a little before the (if I could get it to work) datespinner pops up.
Many thank yous for any help or thoughts! - Chris