我正在使用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的默認功能)。
這個小提琴似乎不再工作了功能改變了嗎? – turbo2oh