FormData doesn't iterate over disabled inputs
If I have a form that looks like this:
<form>
<input disabled name="first_name" />
<input name="last_name" />
</form>
And then I use FormData
to iterate over the inputs.
const form = new FormData(formElement);
const fieldNames = [];
form.forEach((value, name) => {
fieldNames.push(name);
});
// fieldNames contains ['last_name']
Then fieldNames
only contains one name!
Be careful if you're using FormData to extract names from a form!
Tweet