Welcome Guest, Not a member yet? Register   Sign In
Pass Arguments in Custom Validation function
#1

[eluser]abhinavp[/eluser]
Hello There,

I need to ask that can we pass arguments in custom form validation function? I tried it but according to codeigniter standard first argument is by default value of that element and then we can pass our own arguments but not more then one as i experience? Following is my rule reference and function made by me to validate date:
Code:
$this->form_validation->set_rules('StartDate', 'Start Date', 'trim|callback_valid_date[d-m-y, -]');

Code:
function valid_date($date, $format, $delemiter) {         $date_explode = explode($delemiter, $date);         if(count($date_explode) == 3) {             $return = false;             switch ($format) {                 case 'd-m-y'    :   checkdate($date_explode[1], $date_explode[0], $date_explode[2]) == true ? $return = TRUE : $return = FALSE;                                     break;                 case 'm-d-y'    :   checkdate($date_explode[0], $date_explode[1], $date_explode[2]) == true ? $return = TRUE : $return = FALSE;                                     break;                 default         :   $return = FALSE;                                     break;             }             $this->form_validation->set_message('valid_date', '%s field has not valid date.');             return $return;         } else {             $this->form_validation->set_message('valid_date', '%s field has not valid date.');             return FALSE;         }     }


It always return me error that "Missing Argument 3".

Please reply me ASAP.




Theme © iAndrew 2016 - Forum software by © MyBB