在这里,我以 % 输入税收字段,但是当我输入 2.5,0.5 之类的值而不是整数时,它会产生错误。这是我的验证代码,输入浮点数的任何想法
function _set_rules()
{
$this->form_validation->set_rules('pst','PST','trim|required|is_natural|numeric|
max_length[4]|callback_max_pst');
$this->form_validation->set_rules('gst','GST','trim|required|is_natural|numeric|
max_length[4]|callback_max_gst');
}
function max_pst()
{
if($this->input->post('pst')>100)
{
$this->form_validation->set_message('max_pst',' %s Value Should be less than or equals to 100');
return FALSE;
}
return TRUE;
}
function max_gst()
{
if($this->input->post('gst')>100)
{
$this->form_validation->set_message('max_gst',' %s Value Should be less than or equals to 100');
return FALSE;
}
return TRUE;
}
</code>