insin / get-form-data

Gets form and field data via form.elements

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checkbox boolean value?

tnusraddinov opened this issue · comments

How to get boolean values instead 'on'/'off'

Just add a value="whatever" to your checkbox and then filter it:

const data = getFormData(e.target);
for (let key in data) {
  if (data[key] === "whatever") {
    data[key] = true;
  }
}