@NaQu2003
Posted
It looks cool, but it would be even better if u implemented a logic that throws an error when user selects above 28 day or 29 year in specific year in February, or when someone sets 31 days in moth that has only 30 days.
@andreasremdt
Posted
@NaQu2003 Thank you for your feedback! That should already be the case. Try to enter "2022/02/30" as an example, it'll display the error "Must be a valid date" according to the design provided by Frontend Mentor.
@NaQu2003
Posted
@andreasremdt It does not throw an error my mate i can even put 31 days in february
@andreasremdt
Posted
@NaQu2003 My apologies, I only tested in Firefox. In Chrome it didn't work indeed. The reason was that I used Date.parse
to validate the date input, but as it turns out, JS engines implement this function differently. An invalid date (such as Februray 31) results in NaN
in Firefox but returns a valid timestamp in Chromium. I changed the validation slightly to accommodate for this inconsistent behavior, it should work now. Thanks for pointing that out!