ct-form

custom tag form

Usage no npm install needed!

<script type="module">
  import ctForm from 'https://cdn.skypack.dev/ct-form';
</script>

README

form (upgrade)

In order for this plugin to work in older browsers, includ webcomponents.js plugin   https://github.com/webcomponents/webcomponentsjs



How to use it


1. Include js file in footer of the page

<script src="build/ct-form.min.js"></script>

2. Using in html

<form is="ct-form" name="example">
  <input type="text" name="name"/>
  <input type="email" name="email"/>
</form>

3. Access

// using global access: form + [name]
// when form name="example"
formExample.method();


Methods

  • toJson() - get data from all children inputs
  • toFormData() - get data from all children inputs, used formData for files
  • clear() - Clear all children inputs
  • get() - get value from one input by name
  • add() - add key to data, not change input

Attributes

  • is="ct-form" - for using modificator -required
  • data-id - must be unique in one page -required