Input[type="date"] returns a value only if all the segments( / /___) are filled with proper values. Is there a way to know if any of the segments is filled?
No, the values that you see (eg 05/02/
) only exist in the UI layer. The value of the DOM element becomes ""
anytime the parsing as a Date fails, and it is set to "yyyy-mm-dd"
anytime the parsing as a Date succeeds.
The spec: https://dev.w3.org/html5/spec-LC/states-of-the-type-attribute.html#date-state
Quote regarding parsing/validation:
The value sanitization algorithm is as follows: If the value of the element is not a valid date string, then set it to the empty string instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.