下午好,Vaildate動態添加陣列輸入 - jQuery驗證
動態字段被添加與jQuery和我使用jQuery驗證插件來驗證表單。
創建動態字段的代碼取決於選擇框中選定選項的數量。
$('#ids_noct').on('change', function() {
var tsd = (this.value);
for(var j=1; j <= tsd; j++) {
$("#t").append("<input name="name_ct[]" id="id_ct' + j + '" type="text"
class="form-control" placeholder="Add Variant' + j + ' Name" >");
}
});
jQuery代碼來驗證:
$("#formsx").validate({
rules: {
"name_ct[]": {required: true}
}
但隨着這只是第一場得到驗證,不是全部。
假設如果我添加了5個字段,那麼5箇中的1個是驗證,而不是全部。
另外,我想知道,我可以上傳圖像使用PHP和jQuery驗證。 });
我會downvote愛但解釋,請...不知道爲什麼人們害怕給出Downvote – Gags