Welcome Guest, Not a member yet? Register   Sign In
Form validation: Callback not changing the input value
#3

[eluser]Nis Sarup[/eluser]
Here is the callback:
Code:
function _validate_birthday()
        {
            // Validates the birthdate from the user input.
            $day     = (int)$this->input->post('birthday');
            $month    = (int)$this->input->post('birthday_month');
            $year    = (int)$this->input->post('birthday_year');
            
            if (0 > $day || $day > 32) {
                $this->validation->set_message('validate_birthday', 'Invalid day in birthdate.');
                return false;
            }
            
            if (0 > $month || $month > 13) {
                $this->validation->set_message('validate_birthday', 'Invalid month in birthdate.');
                return false;
            }
            
            if (0 > $day || $day > (int)date('Y')) {
                $this->validation->set_message('validate_birthday', 'Invalid year in birthdate.');
                return false;
            }
            
            $birthday = mktime(0, 0, 0, $month, $day, $year);
            
            if ($birthday > strtotime('-18 years')) {
                $this->validation->set_message('validate_birthday', 'You must be 18 years old to sign up.');
                return false;
            }
            
            return $birthday;
        }

It looks at the 3 inputs for the birthday, makes the timestamp and returns it if everything is allright.


Messages In This Thread
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:08 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:13 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:16 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:24 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:27 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:35 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:38 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:42 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:43 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 05:58 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:05 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:20 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 06:33 AM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:21 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:24 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 12:49 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 01:31 PM
Form validation: Callback not changing the input value - by El Forum - 07-02-2009, 01:38 PM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 08:50 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:20 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:52 AM
Form validation: Callback not changing the input value - by El Forum - 07-09-2009, 11:59 AM
Form validation: Callback not changing the input value - by El Forum - 07-16-2009, 10:27 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 08:23 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 09:42 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:00 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:18 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 11:58 AM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 12:26 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 01:53 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 04:21 PM
Form validation: Callback not changing the input value - by El Forum - 08-07-2009, 05:50 PM
Form validation: Callback not changing the input value - by El Forum - 09-03-2009, 12:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB