i want to vaidate the user input of a form
the form uses 3 dropdown boxes named
dobday values 1-31
dobmonth values jan-dec
dobyear values 2009 - 1900
i want to only allow people aged over 16 im guessing i will need to call current day month year and do some can of maths but havent got a clue how to structure it.
i know im using a dropdown so user can only select one of the values but i also want to double check a make sure each feild is one of the values(this help prevent people using there own forms)
so what to also check
dobday = a single or double number ranging from 1-31
dobmonth = can only be letters being between 3(shortest month) characters and 9(longest month) characters
dobyear = 4 digit number between 2009 and 1900
ive been told theres some programs that can do the form validation for me. i did find and try it but it didnt satisfy all my requirements.
can any one recomend any that could do what i am asking. i dont mind paying if it is a decent one
form validation
Moderator: General Moderators
Re: form validation
Assuming you know php and how to process a form...you can use the get_age function I posted here about 5 posts down viewtopic.php?f=1&t=102259
to verify they are over 16.
That will be one million dollars.
to verify they are over 16.
That will be one million dollars.
Re: form validation
Damn, I have to remember: cash first, then code....
Re: form validation
Hi,
Use the below code, This will help you to calculate the age
<?php
$birthday = '07-07-2004';
$today = date('d-m-Y');
$a_birthday = explode('-', $birthday);
$a_today = explode('-', $today);
$day_birthday = $a_birthday[0];
$month_birthday = $a_birthday[1];
$year_birthday = $a_birthday[2];
$day_today = $a_today[0];
$month_today = $a_today[1];
$year_today = $a_today[2];
$age = $year_today - $year_birthday;
if (($month_today < $month_birthday) || ($month_today == $month_birthday && $day_today < $day_birthday))
{
$age--;
}
?>
Thanks
Use the below code, This will help you to calculate the age
<?php
$birthday = '07-07-2004';
$today = date('d-m-Y');
$a_birthday = explode('-', $birthday);
$a_today = explode('-', $today);
$day_birthday = $a_birthday[0];
$month_birthday = $a_birthday[1];
$year_birthday = $a_birthday[2];
$day_today = $a_today[0];
$month_today = $a_today[1];
$year_today = $a_today[2];
$age = $year_today - $year_birthday;
if (($month_today < $month_birthday) || ($month_today == $month_birthday && $day_today < $day_birthday))
{
$age--;
}
?>
Thanks