0

I Have 3 <select> in html from to select date

  • First is for date (1-31)
  • Second is for month (1-12)
  • Third if for year 1990 - 2018

How can in get in php that user selected invalid date. Such as 31 September 2017 or 29 Febraury 2014 etc. Thanks

Yasir Mushtaq
  • 158
  • 1
  • 13

1 Answers1

0

It is a bit long winded doing this with any form of validation like Javascript or PHP.

I would recommend Javascript and there is a source to read from here:

https://www.w3resource.com/javascript/form/javascript-date-validation.php

However why not just change your SELECT statement to this:

<input type="date" name="date" required />

This removes any need to check the date is valid, works on all browsers, is mobile friendly...etc. and if you need to you can add on more controls like must be in future or only so many days from now...etc. relatively simply.

James
  • 190
  • 2
  • 4
  • 13