Thanks dm03514. I got it working using the callback function below.
$this->form_validation->set_rules('first_field', 'First Field', 'trim|required|is_natural'); $this->form_validation->set_rules('second_field', 'Second Field', 'trim|required|is_natural_no_zero|callback_check_equal_less['.$this->input->post('first_field').']');
and callback function:
function check_equal_less($second_field,$first_field) { if ($second_field <= $first_field) { $this->form_validation->set_message('check_equal_less', 'The First &/or Second fields have errors.'); return false; } else { return true; } }
Now everything works fine :)
source share