2

I want to have one validation for two input
ex I have input agendaCode and agendaNumber
I want codeigniter check the concation value of both input at the same time so I will have code like

$this->form_validation->set_rules('agendaCode/agendaNumber','my_callback_function);

but its return error


i know the answer by using

$this->form_validation->set_rules('agendaCode','my_callback_function[agendaNumber]');

2 Answers 2

1

You can only pass one field name to the set_rules() method when doing it that way:

However, you can pass an array:

So:

$config = array(
    array(
         'field' => 'agendaCode',
         'label' => 'Agenda Code',
         'rules' => 'callback_my_function'
    ),
    array(
         'field' => 'agendaNumber',
         'label' => 'Agenda Number',
         'rules' => 'callback_my_function'
    )
);

$this->form_validation->set_rules($config); 
Sign up to request clarification or add additional context in comments.

Comments

0

I mnot sure if you can validate two input in the same statement but i can see why you get an error

you need to change $this->form_validation->set_rules('agendaCode/agendaNumber','my_callback_function);

to

$this->form_validation->set_rules('agendaCode','callback_function); $this->form_validation->set_rules('agendaNumber','callback_function);

the corrent statement is callback_functionname it has to be callback not my_callback or anotherthing else

reference For

1 Comment

actually i want to have a parameter in my callback function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.