对codeigniter的float数字验证检查

Nis*_*Lad 2 php validation numbers codeigniter

在这里我是%的税收领域%但是当我的值为2.5,0.5而不是整数时它产生错误.这是我的验证代码,__CODE__当关联的带有类的nib文件时,调用任何输入浮点数的想法 装了.任何可以拥有笔尖的类都可以使用它.__CODE__仅供视图控制器使用.它通常在从nib加载时调用,但也可以由在内存中创建的视图调用(非常罕见的情况).如果你使用控制器,那么我建议你使用__CODE__

更多信息请参阅此答案

Moe*_*oes 13

is_natural从验证规则中删除并将其替换为greater_than[0]less_than[100]

function _set_rules()
{
  $this->form_validation>set_rules('pst','PST','trim|required|
  greater_than[0]|less_than[100]|max_length[4]|callback_max_pst');
  $this->form_validation->set_rules('gst','GST','trim|required|
  greater_than[0]|less_than[100]|max_length[4]|callback_max_gst');
}
Run Code Online (Sandbox Code Playgroud)

greater_than[0] 将应用 numeric