"Verify your age" not working on tablets or i-phones
Good morning;
Using Responsive Classic template. One of my customers pointed this out to me, when you go into "login" on my website to set up an account, it ask you to verify your age. When I do this on my desktop, I'm able to put the age in as MM/DD/YYYY. However when you go into "login" on a tablet or i-phone, it gives you a calendar. It then does not like the calendar age and will not let you log in. I checked the error logs for my website and there is nothing there for this. What setting do I need to change or is there an error in the code somewhere?
Thank you,
David
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
pazdar
Good morning;
Using Responsive Classic template. One of my customers pointed this out to me, when you go into "login" on my website to set up an account, it ask you to verify your age. When I do this on my desktop, I'm able to put the age in as MM/DD/YYYY. However when you go into "login" on a tablet or i-phone, it gives you a calendar. It then does not like the calendar age and will not let you log in. I checked the error logs for my website and there is nothing there for this. What setting do I need to change or is there an error in the code somewhere?
Thank you,
David
I'm remembering an iOS date-related issue in the past. You can add some debug code to /includes/functions/functions_dates.php (around line 60):
Code:
function zen_valid_date(string $date, string $format = DATE_FORMAT): bool
{
trigger_error("zen_valid_date($date)");
// Build 3 formats from 1 with 3 possible separators
$format0 = str_replace('-', '/', $format);
$format1 = str_replace('/', '-', $format);
$format2 = str_replace(['/','-'], '', $format);
$d0 = DateTime::createFromFormat('!' . $format0, $date);
$d1 = DateTime::createFromFormat('!' . $format1, $date);
$d2 = DateTime::createFromFormat('!' . $format2, $date);
return ($d0 && $d0->format($format0) == $date) || ($d1 && $d1->format($format1) == $date) || ($d2 && $d2->format($format2) == $date);
}
Once that's added, give the create-account another try and post the logged results.
Re: "Verify your age" not working on tablets or i-phones
It seems the calendar returns a date in the "YYYY/MM/DD" format.
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
pilou2
It seems the calendar returns a date in the "YYYY/MM/DD" format.
Thanks for that, @pilou2.
Re: "Verify your age" not working on tablets or i-phones
Actually, it is more complicated than that. The date format provide by the iPhone date picker depends on 'language and region' settings.
I tried few variation on my old iPhone, iOS 15, and got those results:
- Region USA, language English -> June 21 2025
- Region France, language French -> 21 juin 2025
- Region Japan, language whatever -> 2025/06/21
On new iPhones with iOS 17, there is a separate setting for date format which might help if set on numeric format but anyway, these are completly independant of Zen Cart language/regional settings...
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
pilou2
Actually, it is more complicated than that. The date format provide by the iPhone date picker depends on 'language and region' settings.
I tried few variation on my old iPhone, iOS 15, and got those results:
- Region USA, language English -> June 21 2025
- Region France, language French -> 21 juin 2025
- Region Japan, language whatever -> 2025/06/21
On new iPhones with iOS 17, there is a separate setting for date format which might help if set on numeric format but anyway, these are completly independant of Zen Cart language/regional settings...
Were those results the date returned by the form or the date displayed by the form?
From my read of the HTML specification on the date field (https://html.spec.whatwg.org/multipa...id-date-string) the value returned is of the form YYYY-MM-DD.
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
lat9
The date displayed by the form. And of course they failed the validation.
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
pilou2
The date displayed by the form. And of course they failed the validation.
OK, but in all cases, was the value returned in YYYY-MM-DD format? That would, most likely, fail validation as well.
Re: "Verify your age" not working on tablets or i-phones
Quote:
Originally Posted by
lat9
OK, but in all cases, was the value returned in YYYY-MM-DD format? That would, most likely, fail validation as well.
I think so, I don't really know how to check that on iPhone. But if I use a Japanese ZC set to Japanese which accepts the date format YYYY/MM/DD, then I am able to create an account even with the displayed date in French format like '21 juin 2025'.