'Problem: Date input onchange running function on number keys input
I have 2 date fields; end_date
and to_date
. When end_date
is set to before to_date
it changes to_date
to the value of end_date
.
The problem I'm having is if the user types in the date field rather than using the calendar picker, it accepts each of the keypresses as a valid date.
For example: Both end_date
and to_date = 18/10/2022
The user wants to change end_date
to a later date (ex 20/11/2022), so in theory it should not change to_date
.
When the user then goes to type 20 the date field will run the function with the date 02/10/2022
, thus changing to_date
(because typing "2" will change the date to 02).
The only solution I have right now is just making it impossible for the user to use number keys in the field, however this is not optimal. Does anyone have a better solution?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|