I have a simple web form to collect subscribers birthdays. By default adding the field as a date field seems to be problematic, since on mobile is opens a date picker (which is a PITA, and unnecessary, to enter a birthday).
I’d like to find a way to let the user enter the date into MM-DD-YYYY but convert it to ISO8601 on submti, with no datepicker being used at all.
Then after submission, validate with a PHP REGEX and convert the posted date to ISO8601
<?php
if (preg_match('`\d{2}-\d{2}-\d{4}`', $_POST['bday'])) {
$iso = preg_replace('`(\d{2})-(\d{2})-(\d{4})`', '$3-$2-$1', $_POST['bday']);
} // not tested, but this is the idea