New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

formaggino

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formaggino

A small vanilla js library for validate your forms

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

GitHub

🧀 Formaggino

A small vanilla js library for validate your forms without external dependencies

Getting started

Install the package

npm install formaggino

Initialize the library

import Formaggino from "formaggino";
const formaggino = new Formaggino();

Create a form remember to include method, action and novalidate on your form

<form
  method="POST"
  id="form"
  action="https://your-action.io/sendform"
  novalidate
>
  <input name="name" type="text" required />
  <span class="form-error">Your error text</span>
  ...
  <div class="form-report-error">error</div>
  <div class="form-report-success">success</div>
  <span class="form-loading"> loading... </span>
  <button type="submit">submit</button>
</form>

call the submitEvent method

formaggino.submitEvent("#form");

or use the options

formaggino.submitEvent("#form"{
  mode: 'json',
  loadingClass: 'your-loading__custom_class',
  closingTimint: 8000
  ...
});

don't forget to set you css

.form-error,
.invalid-feedback,
.form-loading,
.form-report-error,
.form-report-success {
  display: none;
}

.active {
  display: block;
}

Options

OptionTypeDefaultDescription
modestringform-datathe type of data to send to fetch request, you can also use json
loadingClassstringform-loadingthe css class for loading element
errorClassstringform-errorthe css class for each single field of form
formSuccessstringform-report-successthe css class for form success element
formErrorstringform-report-errorthe css class for form error element
closingTiminginteger3000timeout for form report duration
listenerstringchangethe event listener for each single field in form

Contributing

Build for development

  • Having all the dependencies installed run npm run dev. This command will generate UMD (unminified), CommonJS and ESM modules under the dist folder. It will also watch for changes in source files to recompile.

Build for production

  • Having all the dependencies installed run npm run build. This command will generate the same modules as above and one extra minified UMD bundle for usage in browser.

Scripts

  • npm run build - Produces production version of library modules under dist folder.
  • npm run dev - Produces a development version of library and runs a watcher to watch for changes.
  • npm run test - Runs the tests.
  • npm run lint - Lints the source code with ESlint.
  • npm run prepare - Run both BEFORE the package is packed and published, on local npm install without any arguments, and when installing git dependencies.
  • npm run clean - Deletes dist and coverage folders.
  • npm run serve - serve the index.html with http-server

License

The MIT License (MIT)

FAQs

Package last updated on 06 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc