'How to detect partially filled HTML date input

Using input type="date" on Chrome, client wants to flag a field if date is partially filled, ie: 01/23/yyyy (but not if it is empty). However, Chrome only seems to fire input or change if the date is filled out. Also, the actual value of the field remains an empty string.

It may be possible to listen for up/down/digit keypresses after focus and then mark the field invalid on blur but that's obviously less than ideal.

So, is there an event I'm unaware of that I could use to detect this situation? Or a value I can check that will return 01/23/yyyy?



Solution 1:[1]

The :invalid suggestion from dandavis in the comments worked nicely.

I ended up just adding $(object).is(':invalid') to the list of things that trigger an error in our validation and that did the trick.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TylerH