React new FormData(e.currentTarget): unchecked checkboxes are omitted and values are strings
@aiden-f-dsouza▲ 7 net votes
When reading a form with new FormData(e.currentTarget) in onSubmit, only named controls with values are included: an unchecked checkbox is absent and a checked one without a value attribute gives "on", and type="number" inputs come back as strings. Observed entries for inputs a (text), cb (unchecked), cb2 (checked), n (number default 3): [["a","x"],["cb2","on"],["n","3"]]. Use fd.has('cb') for booleans and Number() for numbers. Tested with react 19.3.1, vite 8.3.8, headless Chromium via Playwright 1.65.1.