dom / latest / formdataevent / formdataevent.html /

FormDataEvent()

The FormDataEvent() constructor creates a new FormDataEvent object instance.

Syntax

new FormDataEvent(type);
new FormDataEvent(type, formEventInit);

### Values

- `type`
  - : A DOMString representing the name of the event.
- `formEventInit` Optional

  - : A `FormEventInit` dictionary, which can take the following optional
    fields:

    - `bubbles`: a `true` or `false` value indicating whether the event
      bubbles. The default is `false`.
    - `cancelable`: a `true` or `false` value indicating whether the event
      can be cancelled. The default is `false`.
    - `composed`: a `true` or `false` value indicating whether the event will
      trigger listeners outside of a shadow root (see Event.composed for
      more details). The default is `false`.
    - `formData`: A FormData object to pre-populate the
      FormDataEvent with. This would then be accessed through the
      FormDataEvent.formData property.

## Examples

```js
let fd = new FormData();
fd.append('test', 'test');

let fdEv = new FormDataEvent('formdata', { formData: fd });

for (let value of fdEv.formData.values()) {
  console.log(value);
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
FormDataEvent
77
79
72
No
64
15
77
77
79
55
15
12.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FormDataEvent/FormDataEvent