私は、配列を介してフィールドを送信してユーザーを指定する前にこれらのフィールドを検証し、何も追加されていないため、動的テキストフィールドを生成するコードを調査しました。私はこれまで行ってきたことのリンクを残す。 を検証しますか?
<label for="PASIVOS">Data Enter</label>
<div class="input_fields_wrap1">
<input class="add_field_button1" type="button" value="+ Add" />
</div>
のyこのコードはjQuery
$(document).ready(function() {
var max_fields = Infinity; //maximum input boxes allowed
var wrapper1 = $(".input_fields_wrap1");
var add_button1 = $(".add_field_button1"); //Add button
var x = 1; //initlal text box count
$(add_button1).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper1).append('<div>Product <input type="text" name="Product[]"/> Price <input type="text" name="Price[]"/> Quantity <input type="text" name="Quantity[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
$(wrapper1).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
});
https://jsfiddle.net/sarrhen/L6kdzLco/
私が欲しいものをjQueryを使って非常に良いではないよにアラートを表示することですフィールドが必要であることを示すテキストフィールドのペアd
が何かを成し遂げるだけ最初の入力を行うこと私と他者を検証:中として
別のオプション、正規表現を使用することです。その場合はそうは以下のようにあなただけの、jquery's
.isNumeric()
functionを使用することができます生成しないでください http://jsfiddle.net/sarrhen/6cuu4rpw/ –