2013-04-04 80 views
0

所以我有簡單的註冊表單和一些奇怪的原因,一些驗證工作,一些沒有。我爲conern的語言定義了一個單獨的語言文件夾,即阿拉伯語。它適用於用戶名,密碼和密碼確認,但不適用於其他字段。出了什麼問題?codeigniter無法識別一些驗證

public function registration() 
    {  
      $this->form_validation->set_rules('fullname', 'الاسم الكامل', 'isset | required | alpha'); 
      $this->form_validation->set_rules('username', 'اسم المستخدم', 'required'); 
      $this->form_validation->set_rules('password', 'كلمة السر', 'required'); 
      $this->form_validation->set_rules('passconf', 'إعادة كلمة السر', 'required'); 
      $this->form_validation->set_rules('email', 'الايميل', 'required |email'); 
      $this->form_validation->set_rules('city', 'المدينة', 'required'); 
      $this->form_validation->set_rules('userfile', 'صورة الملف الشخصي', 'upload_no_file_selected'); 


      if($this->form_validation->run() == FALSE) 
      { 
       $this->index(); 
      } 
      else{ 
       $this->user_model->add_user(); 
       $this->thank(); 
      } 

     } 

形式:

<html> 
<head> 
<title></title> 
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> 

</head> 
<body dir="rtl"> 

<?php echo validation_errors(); ?> 

<?php echo form_open_multipart('membership/registration'); ?> 

<h5>الإسم الكامل</h5> 
<input type="text" name="fullname" value="" size="80" /> 

<h5>اسم المستخدم</h5> 
<input type="text" name="username" value="" size="50" /> 

<h5>كلمة السر</h5> 
<input type="text" name="password" value="" size="50" /> 

<h5>إعادة كلمة السر</h5> 
<input type="text" name="passconf" value="" size="50" /> 

<h5>الايميل</h5> 
<input type="text" name="email" value="" size="50" /> 

<h5>المدينة</h5> 
<select name="city"> 
    <option value="riyadh">الرياض</option> 
    <option value="jeddah">جدة</option> 
    <option value="dhahran">الظهران</option> 
    <option value="mecca">مكة</option> 
</select> 

<h5>صورة الملف الشخصي</h5> 
<input type="file" name="userfile" size="20" /> 
<br><br> 

<div><input type="submit" value="Submit" /></div> 

</form> 

</body> 
</html> 

感謝幫助,

+0

您是否在控制器的構造函數或自動加載配置文件中加載了適當的庫和幫助程序? – 2013-04-04 13:08:08

+0

是的,我已經完成了。正在對用戶名,密碼和passconf進行驗證。但沒有任何其他領域。 – 2013-04-04 13:08:56

+0

如果您嘗試將英文字符放在驗證規則上,它是否有效? – 2013-04-04 13:12:56

回答

0

刪除驗證規則之間的空間是這樣的:

$this->form_validation->set_rules('fullname', 'الاسم الكامل', 'isset|required|alpha'); 
+0

哈哈感謝隊友我剛剛發佈了相同的答案我自己的問題 – 2013-04-04 13:20:34

+0

我很高興你找到它。 我第一次看到你的代碼時沒有注意到空格:) – 2013-04-04 13:21:33

0

我找到了答案,哦,是它愚蠢!只需刪除驗證規則之間的空格,它就可以工作了!所以例如

alpha|isset|required