2014-10-08 75 views
1

我想用一個小圖標,以紅色顯示的登錄錯誤之前,我只是說由錯誤的驗證信息,如:自定義錯誤風格

public $validate = array(
    'email' => array(
    'rule'  => 'email', 
    'required' => true, 
    'message' => 'Please enter your email adress' 
) 
) 

我讀過這些下面的行在CSS會做到這一點,但實際上它沒有與我一起工作,有什麼想法?

.error-message { 
    background:url(path/to/img.png) no-repeat top left; 
    padding-left:40px; /* or whatever you need for the image to fit */ 
} 

回答

0

使用以下

div.error消息相反.error消息的

所以使用

div.error-message { 
    background:url(path/to/img.png) no-repeat top left; 
    padding-left:40px; /* or whatever you need for the image to fit */ 
} 

而且

' 'rule'  => 'email',` 

是對HTML5客戶端驗證所以你不能修改它,但是你可以使用斷斷續續的規則使用服務器端驗證。

1

我認爲驗證錯誤和setFlash消息有id =「authMessage」和class =「message」。嘗試在瀏覽器中檢查驗證消息的元素,以便查看它使用的id或類。

我希望它可以幫助你。 :)

+0

謝謝我完全忘了檢查瀏覽器中的元素。 該類是:錯誤消息,爲什麼它不工作:/? '

Please enter your email
' – Exchanger13 2014-10-08 05:37:35