嘗試在CodeIgniter
中爲min_length
和max_length
驗證約束設置自定義驗證消息時出現錯誤。驗證codeigniter中的max_length,min_length
這是我的驗證規則:
$this->form_validation->set_rules('username', 'Username', 'required|xss_clean|min_length[6]|max_length[10]');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[8]|max_length[20]';
這些都是我的定製驗證消息:
$this->form_validation->set_message('min_length[3]', '%s: the minimum of characters is three');
$this->form_validation->set_message('max_length[20]', '%s:the maximum of characters is 20');
在我的例子中,我們有兩個領域,但我有不同的最小和最大長度諸多領域值。他們都有一個特定的約束驗證。此消息不起作用。該消息默認顯示。謝謝你的幫助。
在我的源代碼中沒關係。當我做我的職位時,我忘記了關閉沮喪。我的懷疑繼續。感謝您的更正。 – cabita
@cabita - 我已經更新了我的答案。 – stealthyninja
謝謝,我會審查你的答案。謝謝。 – cabita