View Full Version : Check Age With SeverValidation
Cologne
10-19-2009, 12:55 PM
Hi,
how can I check (serverside) the age with VTK2?
I got the field "birthday" dd.mm.yyyy this the Fomat I check it against. Now I want th faile if the age is under 14 years. So it must be the field min. Date.
But what do I put in there to check if the birthday is older that 14 years?
Cheers
Denis
Jason Byrnes
10-19-2009, 02:23 PM
use this for the minimum date:
<?php echo(date("d/m/Y", mktime(0, 0, 0, date("m"), date("d"), date("Y") + 14))); ?>
Cologne
10-19-2009, 10:15 PM
Jason,
that does not work :-(
http://www.ringfieber.de/Register/register.php
Jason Byrnes
10-20-2009, 09:45 AM
Rather than just say it does not work, it would be more helpful if you could describe the scenario that you are testing that does not work for you.
it seams to work for me.
If I enter:
21.10.2023
it will validate the date
If I enter:
14.10.2023
it will not.
If you could describe what you are expiring, it would take out the back and forth of having me test something different.
Cologne
10-20-2009, 10:08 AM
Hi,
<?php echo (date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y") - 14))); ?>
does not work.
if you are born 20.10.1995 you can enter, if born 21.10.1995 then NOT.
so the date must in this case be earlier that 20.10.1995
how to check that?
thanks,
Denis
Jason Byrnes
10-20-2009, 10:25 AM
Ok, so the math was backwards. Instead of 'date("Y") + 14" use "date("Y") - 14"
<?php echo(date("d/m/Y", mktime(0, 0, 0, date("m"), date("d"), date("Y") - 14))); ?>
much easier to tell what "doesnt work" when I know "whats wrong"
Cologne
10-20-2009, 10:41 AM
no, that does not work, too.
I put that into min Date:
<?php echo (date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y") - 14))); ?>
that is exactly the diffrent I want. now you can enter if you a born BIGGER that 20.10.1995.
but then you are younger.
you only should enter if you are born before 21.10.1995
i dont know how to tell.
Jason Byrnes
10-20-2009, 10:43 AM
That should go in the maximum date.
Cologne
10-20-2009, 10:47 AM
YES!
Thats it, great!
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.