New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

form.js

Package Overview
Dependencies
Maintainers
9
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form.js

Automagic form validation and submission library.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
9
Created
Source

Form.js

npm build dependencies downloads license chat

Automagic form validation and submission.

Install

npm install form.js

Or drop it inside a <form> and let it wire itself to the surrounding fields:

<form>
  <script src="https://unpkg.com/form.js" data-key="pk_live_…"></script>
  <input name="email">
  <button type="submit">Sign up</button>
</form>

Submission

Without a key, form.js is a thin controller around the surrounding form: it emits lifecycle events and hands control back to your page. Set a Hanzo publishable key on the script tag and it POSTs the serialized form to the Hanzo forms ingest instead:

POST https://api.hanzo.ai/v1/forms
Authorization: Bearer pk_live_…
Content-Type: application/json

{ "email": "ada@example.com", "metadata": { "name": "Ada" } }

Script-tag options (all data-*):

attributepurpose
data-keypublishable key (pk_live_… / pk_test_…)
data-token@hanzo/iam access token (takes precedence over key)
data-endpointoverride the full submission URL
data-hostoverride the API host (default https://api.hanzo.ai)

Events

window.Inform is an event emitter — listen with Inform.on / Inform.once:

eventInform.Eventsarguments
init-inform-scriptInitScriptthe <script> element
init-inform-formInitFormthe <form> element
init-inform-inputsInitInputsarray of input/select nodes
init-inform-submitsInitSubmitsarray of submit buttons
inform-submitOnSubmitunmanaged: (done, event); managed: (payload, event)
inform-doneOnDonethe submit event, or the API response (managed)
inform-errorOnErrorsubmission error (managed)

In unmanaged mode, call done() from your OnSubmit listener to let the native form submit proceed.

License

BSD

Keywords

form

FAQs

Package last updated on 24 Jul 2026

Related posts