1 回答
TA贡献1993条经验 获得超5个赞
function prepareOCPDepEntries(formEl) {
const formData = new FormData(formEl);
let res = "";
for (var pair of formData.entries()) {
console.log(pair[0])
if (pair[0].startsWith("_")) {
console.log(pair[0])
res = res + "|" + pair;
formData.delete(pair[0]);
}
}
console.log([...formData.entries()]); // Works. There's only one entry in the Iterator
document.getElementById("depEntry").value = res;
document.forms.mainForm.disabled = true;
}
document.querySelector("#mainForm").addEventListener("submit", function(ev) {
ev.preventDefault();
prepareOCPDepEntries(this);
})
<form id="mainForm">
<input value="123" name="_0.0" type="text">
<input value="999" name="bar" type="text">
<button>Submit</button>
</form>
<textarea id="depEntry"></textarea>
添加回答
举报