OK I want to restrict the age of anybody registering on my site to be
a minimum of 18 years of age. I set up the validation rule in my model
like this:

'dateofbirth' => array(
                        'valid' => array(
                'rule' => array('vDob'),
                'message' => 'Must be above 18 years old'
                 ),
                )

and then below added this function still in the model file

//Ensure the date of birth entered is older than 18 years
function vDob($field) {
    $user_bd = strtotime($field['dateofbirth']);
    $age_req = strtotime('+18 years', $user_bd);

    if  (time() < $age_req) {

        return false;
    } else {
        return true;
    }

    return true;
}


Is this a good reliable way of doing this?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to