FormData.js 859 B

1234567891011121314151617181920212223242526272829
  1. if (FormData.Inputmask === undefined) {
  2. class FormDataPatch extends FormData {
  3. constructor(form, submitter) {
  4. super(form, submitter);
  5. const entries = this.entries();
  6. let entry;
  7. while ((entry = entries.next()).done === false) {
  8. const fieldName = entry.value[0],
  9. originalValue = entry.value[1], // Get the original value from FormData
  10. element = document.getElementById(fieldName);
  11. if (
  12. element &&
  13. element.inputmask !== undefined &&
  14. !(originalValue instanceof File)
  15. ) {
  16. // Apply masking only if it's not a File and the element has inputmask
  17. this.set(fieldName, element.value);
  18. }
  19. }
  20. return this;
  21. }
  22. }
  23. FormDataPatch.Inputmask = true;
  24. // eslint-disable-next-line no-global-assign
  25. FormData = FormDataPatch;
  26. }