@switch-company/form-utils

Convenience methods for form datas

Usage no npm install needed!

<script type="module">
  import switchCompanyFormUtils from 'https://cdn.skypack.dev/@switch-company/form-utils';
</script>

README

Switch - formUtils

Convenience methods for form datas


.toJSON( HTMLFormElement, Boolean )

Return a JSON object containing the name and values of each field element of the form. If the form contains fields with the same name, the values of those fields will be in an array.

Parameters

  • HTMLFormElement - the form element you want the data from
  • Boolean - Whether or not limit the object to string values. Filter out file inputs. Defaults to false.

.toQuery( HTMLFormElement )

Retrun a query string without the leading ?.

.hasFile( HTMLForElement )

Return true if the form has at least one file input that is not empty.