0

When using HTML5 date and you have DD/MM/YYYY is there a way to validate it using PHP so if DD/MM/YYYY has been left as DD/MM/YYYY it throughs an error?

I guess you cannot use empty() as its not empty.

zkanoca
  • 9,664
  • 9
  • 50
  • 94
Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
  • A similar question has already been answered [here][1] [1]: http://stackoverflow.com/questions/11029769/php-function-to-check-if-a-string-is-a-date-regex – alez007 Aug 23 '14 at 22:12
  • It's not really clear what you're asking. Are you referring to placeholders? Are those even posted to the server? Regardless of what's posted to the server, your server-side validation is the same it's always been. If you're expecting a date, validate the input as a date. The server-side code never had any guarantee that what's being posted was even handled by the intended HTML code. – David Aug 23 '14 at 22:12

1 Answers1

0

HTML5 date inputs will send their value as YYYY-mm-dd format, but will display whatever format is locale-friendly to the user.

If nothing is entered (ie. the input is "blank"), then nothing is sent.

So, on the server, empty will work fine.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592