fluttering-frost-forms
v1.0.2
Published
A lightweight library for creating and managing forms in JavaScript.
Downloads
6
Maintainers
Readme
Fluttering Frost Forms
A lightweight JavaScript library for creating and managing forms with ease.
Installation
Install fluttering-frost-forms
using npm:
npm install fluttering-frost-forms
Usage
First, import FlutteringFrostForms
into your project:
import FlutteringFrostForms from 'fluttering-frost-forms';
Define a schema for your form:
const formSchema = {
username: {
defaultValue: '',
validator: (value) => value.length > 0 && value.length < 20
},
birthday: {
defaultValue: '',
validator: (value) => moment(value, 'YYYY-MM-DD').isValid()
}
};
Initialize your form with the schema:
const myForm = new FlutteringFrostForms(formSchema);
myForm.initializeForm();
Validate and submit the form:
try {
myForm.validateField('username', 'johnDoe');
myForm.validateField('birthday', '1990-01-01');
myForm.submitForm();
} catch (error) {
console.error(error.message);
}
License
This project is licensed under the MIT License.