2010-05-27 35 views

回答

1

設置你的錯誤的div一個類似:

<div id='errors' style="display: none;">Sample Error</div> 

使用jQuery的.show()方法來顯示像格:

if (errors == true){ 
    $("#errors").show() 
} 

如果需要使用的.html()來定製錯誤如:

if (errors == specificError){ 
    $("#errors").html('A specific error has occurred') 
    $("#errors").show() 
} 

永遠記住,jQuery API網站是你最好的朋友。

編輯:我只注意到你提到了jq validate插件,指定了你正在使用的插件,如果需要的話我可以提供更具體的樣本。

2

實現該功能的最佳方法是使用噴淋頭選項。

showerrors選項允許您定義一個函數來顯示您的錯誤。您可以操作此功能來隱藏和顯示錯誤。

這裏是docs