Users would select their date from 3 dropdowns (day, month, year). I will combine them on server-side to make a string like ‘2008-12-30’. How can I then validate to make sure this date was in the right format/numeric only, etc?
Users would select their date from 3 dropdowns (day, month, year). I will combine
Share
If they are 3 separate drop-downs, you will need to validate them as three separate values.
Ie,
Or, you could just cast them all to integer, combine them together into a date, and see if the resulting date is valid. Ie,
The downside to this method is that it’ll only work with dates within the Unix timestamp range ie 1970 to 2038 or so.