@ageesea/micro-form

1.0.9 • Public • Published

Micro helper for HTML Forms

A collection of helper methods for manipulating html form through JS.

Install

In your terminal, run

npm install @ageesea/micro-form

Usage

Method: getFormValues(formSelector, isExcludeEmpty=false)

A method that scans your html form inputs to create an object structure. It uses the name attribute as key and their value as value. It also support array-based names.

<!-- example.html -->
<form id="form-employee">
    <input name="full_name" />   
    <input name="age" />   
    <input name="accounts[]" />   
    <input name="accounts[]" />   
</form>
// example.js
import {getFormValues} from '@ageesea/micro-form'

const values = getFormValues('#form-employee')

Output:

{
    full_name: "Juan dela cruz",
    age: 23,
    accounts: [
        "value1", "value2"
    ]
}

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @ageesea/micro-form

    Weekly Downloads

    0

    Version

    1.0.9

    License

    MIT

    Unpacked Size

    4.43 kB

    Total Files

    6

    Last publish

    Collaborators

    • ageesea