我正在使用select2和jQuery Validation插件。select2驗證 - 選擇最少一個值
HTML的選擇2:
<div class="form-group">
<label for="select2Region"><h3>Set Location</h3></label><br />
<input type="hidden" id="select2Region" style="width:40%" required/>
</div>
選擇2啓動:
$('#select2Region').select2({
minimumInputLength: 1,
data: $.parseJSON(selectRegion),
placeholder: "Enter your City here",
allowClear: true
});
數據填充完美的罰款。現在,我希望用戶選擇一個值。
正如提到in Github,我試圖這樣:
嘗試增加忽略:「」,在該行直接上面的規則:。一個空字符串爲我做了工作,因爲忽略:null,不起作用。
,這也:
$('.select2').select2().change(function(){
$(this).valid();
});
但他們都沒有爲我工作。這樣做的正確方法是什麼?
我甚至不知道如何告訴this.wasted一個小時。出來我錯過了名稱屬性!天哪,我感到尷尬 – spyder
請在問題中顯示您的jQuery驗證碼,然後在下面張貼您的解決方案作爲答案。否則,請隨時舉報刪除。 – Sparky
@Sparky已經更新了答案。那還好嗎? – spyder