我需要确保amount
字段大于amount_left
字段。
$config=array(
array(
'field' => 'amount',
'label' => 'actual amount',
'rules' => 'trim|required'
),
array(
'field' => 'amount_left',
'label' => 'amount left',
'rules' => 'trim|required'
)
)
答案 0 :(得分:0)
试用此代码:
创建一个函数:
希望它能奏效:
function check_bigger($amount,$amount_left)
{
if ($amount >= $amount_left)
{
$this->form_validation->set_message('check_bigger', 'The First &/or Second fields have errors.');
return false;
}
else
{
return true;
}
}
$v$this->input->post('amount_left');
$config=array(
array(
'field' => 'amount',
'label' => 'actual amount',
'rules' => 'trim|required|callback_check_bigger['.$v.']',
),
array(
'field' => 'amount_left',
'label' => 'amount left',
'rules' => 'trim|required'
)