我在输入税收字段时,使用2.5、0.5等整数以外的值会生成错误。以下是我的验证代码,请问如何输入浮点数?
function _set_rules() { $this->form_validation->set_rules('pst','PST','trim|required|numeric| max_length[4]|callback_max_pst'); $this->form_validation->set_rules('gst','GST','trim|required|numeric| max_length[4]|callback_max_gst'); } function max_pst() { if($this->input->post('pst')>100) { $this->form_validation->set_message('max_pst','%s值应小于或等于100'); return FALSE; } return TRUE; } function max_gst() { if($this->input->post('gst')>100) { $this->form_validation->set_message('max_gst','%s值应小于或等于100'); return FALSE; } return TRUE; } </code>
is_natural
。 - Nerdroidgreater_than[0]
和less_than[100]
,并移除is_natural
。 - Nerdroid