Skip to content

A collection of helper methods for managing HTML forms through JS.

Notifications You must be signed in to change notification settings

anthonygacis/micro-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
    ]
}

Roadmap

  • Add more helper functions for html such as:
    • validation
    • etc.