An input date input event of type html5 does not fire correctly with an empty value

This is a strange behavior that I could not isolate in order to accurately reproduce it; however, it seems to happen quite often after using a little "x" before resetting the input. After the reset date, enter the actual date using the keyboard, and then go to the various month / day / year settings.

<input id="pi-start" type="date" data-clear-btn="false" value=""> $('#pi-start').on('input', function() { var value = $('#pi-start').val(); if ( value != '' ) { console.log(value); } else { console.log("Blank"); } }); 

Missing Date Entries

You can see on the console where the month change triggered an input event, but the value for input has not been set.

What is going on here and what is the best way to prevent this? I want to be able to detect a change in value.

Chrome: version 64.0.3282.119 (official build) (64-bit)

0
jquery input html5 events datepicker
source share
1 answer

Of course, as soon as I post a question, I understand what is happening. An empty value is triggered for input because the keyboard allows you to select a date that is not valid. i.e. February 30th.

0
source share

All Articles