2017-02-11 124 views
1
public function doAssignerSU() { 

    $this->form_validation->set_rules('username', 'Username', 'required|alpha_numeric'); 
    $this->form_validation->set_rules('password', 'Password', 'required|alpha_numeric|min_length[4]'); 
    $this->form_validation->set_message('min_length','Minimum of 4 characters'); 

當我在視圖中顯示我的驗證錯誤,但它仍然顯示預設「的{}場必須是最低..」笨set_message不工作

什麼是我的錯?在此先感謝

+0

@Parvez沒有錯誤。它只是沒有爲'min_length'規則設置我的自定義消息。 –

回答

0

設置自定義郵件這樣的..

$this->form_validation->set_rules('password', 'Password', 'required|alpha_numeric|min_length[4]',array('min_length'=>'Minimum of 4 characters')); 

提示:設置規則時,您可以直接設置您的自定義信息。

更多看到Codeigniter Form Validation

+0

向上帝發誓我已經在張貼問題之前輸入了5次。複製你的線不知何故設法做到這一點。無論如何,感謝隊友 –

+0

很高興爲您提供幫助。您可以在設置「規則」時直接設置您的自定義「消息」。祝您好運。 –

+0

@JorelAngeloMolato,是的,這是爲單個元素設置消息時的答案。但是,由於'set_message()'是全局的,所以你最初的錯誤並不是把它放在* set_rules() – Sparky