2014-03-26 72 views
0

我正在使用require_from_group從Jquery驗證框架,我試圖顯示在屬於該組的每個字段中的錯誤消息,但它只被顯示在其中兩個。jquery驗證 - require_from_group

HTML代碼:

<form id="myform"> 
<label for="mobile_phone">Mobile phone: </label> 
<input class="phoneUS contactMethod" id="mobile_phone" name="mobile_phone"> 
<br/> 
<label for="home_phone">Home phone: </label> 
<input class="phoneUS contactMethod" id="home_phone" name="home_phone"> 
<br/> 
<label for="work_phone">Work phone: </label> 
<input class="phoneUS contactMethod" id="Work_phone" name="work_phone"> 
<br/> 
<label for="work_phone">Fax phone: </label> 
<input class="phoneUS contactMethod" id="fax_phone" name="fax_phone"> 
<br/> 
<label for="work_phone">Email: </label> 
<input class="phoneUS contactMethod" id="email" name="email"> 
<br/> 
<input type="submit" value="Go!"> 
</form> 

JS:

$.validator.addClassRules("contactMethod", { 
require_from_group: [1, ".contactMethod"] 
}); 

$("#myform").validate(); 

這是我的jsfiddle: http://jsfiddle.net/3jahT/

我想的是,每當用戶點擊提交,在所有領域的消息出現,以及當用戶沒有填充它們時忽略其中一個。 (Jquery的默認功能)。

+0

這個小提琴似乎不再工作了功能改變了嗎? – turbo2oh

回答

1

報價OP:

「我使用require_from_group從jQuery驗證......我想,以顯示屬於該組的每一個領域的錯誤信息,但它是隻在其中兩個顯示。「

它是與被認爲是固定的,在未來版本(V1.12)的插件(v1.11.1和)之前一個known and reported bug

「我想的是,每當用戶點擊提交,在所有領域出現的消息......」

在等待下一個版本,你可以下載和構建版本1.12 from the latest files available at Github

否則,您可以比較最新文件中的代碼,並僅將適用的更改應用到本地版本的插件。這隻會作爲一個臨時插件,因爲當它發佈時,您會故意用最新版本覆蓋它。

+0

謝謝,我下載了這個特定方法的最新版本。 –