Welcome Guest, Not a member yet? Register   Sign In
[solved]Custom Validation?
#3

[eluser]brucebat[/eluser]
Thanks I used the example to make this:

Code:
function valid_time($str)
            {

                //This part seperates the string into three segments using the ":" as the divide
                $parts = explode(':', $str);
                
                //1st validation checks to make sure there are three parts made from string
                if (sizeof($parts) != 3)
                {
                    $this->form_validation->set_message('valid_time', 'The %s fields has too many time segments');
                    return FALSE;
                }
                
                else
                {
                    //if hours segment is not 24 hour compliant
                    if ($parts[0] < 24 || $parts[0] >= 0)
                    {
                        $this->form_validation->set_message('valid_time', 'The %s fields Hour segment is not correct');
                        return FALSE;
                    }
                    
                    //if minutes segment is not 24 hour compliant
                    else if ($parts[1] < 0 || $parts[1] > 59)
                    {
                        $this->form_validation->set_message('valid_time', 'The %s fields Minute segment is not correct');
                        return FALSE;
                    }
                    
                    //if seconds segment is not 24 hour compliant
                    else if ($parts[2] < 0 || $parts[2] > 59)
                    {
                        $this->form_validation->set_message('valid_time', 'The %s fields Seconds segment is not correct');
                        return FALSE;
                    }
                    
                //validation passed!
                return TRUE;
                }
    
            }

However it does not seem to work when testing it using this call:

Code:
$this->form_validation->set_rules('time'.$i, 'Time'.($i+1), 'required|xss_clean|callback_valid_time'); // time0, time1, time2 etc


Messages In This Thread
[solved]Custom Validation? - by El Forum - 08-02-2011, 10:56 AM
[solved]Custom Validation? - by El Forum - 08-02-2011, 11:36 AM
[solved]Custom Validation? - by El Forum - 08-02-2011, 12:14 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 12:15 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 12:20 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 12:33 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:22 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:28 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:30 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:34 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:35 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:39 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:41 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:43 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:44 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:50 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:53 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:57 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 01:58 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 02:13 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 02:14 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 02:16 PM
[solved]Custom Validation? - by El Forum - 08-02-2011, 02:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB