這裏我是enens稅務字段的百分比,但是當我的enetr值是2.5,0.5而不是整數時,它會產生錯誤.. 這裏是我的驗證碼,任何想法輸入浮點數 float驗證codeigniter的號碼
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>
任何事情,任何提示將工作 –
嘗試從驗證規則中刪除'is_natural' – Moes
@Moes你可以看到我已經把is_natural驗證不允許負數,所以即時得到錯誤,你只能輸入possitve數字 –