I want to make dateTime input with a mask and auto-complete.
I created a small demo where the problem exists.
It seems that autocomplete thinks that the mask is text ... only if I finish typing I can see some value from autocomplete (if it exists in the autocomplete list).
Is there any solution?
<input name="field1" id="field1" class="inputmask" data-inputmask="'mask': 'h:s t\\m','placeholder': 'hh:mm xm', 'hourFormat': '12', 'alias': 'datetime'"/>
function generateTime(){
var times = [];
Array(24).join(',').split(',').forEach(function (_, index) {
var hour = index;
if (hour < 10) {
hour = '0' + hour;
}
times.push(moment(hour + ':00', 'HH:mm').format('hh:mm a'));
times.push(moment(hour + ':30', 'HH:mm').format('hh:mm a'));
});
return times;
}
$('.inputmask').inputmask();
$('.inputmask').autocomplete({
source: generateTime()
});
UPD:
Maybe some kind of starting point for the solution: in case I add the 'autoUnmask' : trueAutoComplete property it will work only on the "clock" - the first characters before my ":" in the mask.
https://jsfiddle.net/vbekLtm6/5/
source
share