Skip to content
FormclickDocs
HTML FormsSubmitting

formclick.min.js

A tiny drop-in script that adds AJAX submits, loading states, inline messages and file uploads to your forms.

formclick.min.js upgrades every form whose action points at Formclick. Your HTML stays the same and still works if JavaScript is off.

HTML
<!-- Handles submit, file upload, loading state and success/error messages. -->
<script src="https://cdn.formclick.io/formclick.min.js"></script>

What it does

  • Submits in the background, so visitors stay on your page.
  • Disables the submit button while sending and adds the fc-btn-loading class.
  • Shows success and error messages inside the form, then resets it.
  • Follows redirects set with the redirect field or in the dashboard.
  • Turns file inputs into upload zones with drag and drop and progress bars.
  • Checks your access key and shows a clear configuration message if it is missing or malformed.
  • Watches the page for forms added later (modals, SPA routes) and enhances them automatically.
  • Works with captchas: checks that a reCAPTCHA or Turnstile widget is completed before sending, fetches reCAPTCHA v3 tokens, and resets the widget after each attempt.
yourwebsite.com/contact
Contact us
Jane Smith
you@example.com
Write your message…
Send message
Thanks! Your message has been sent.
No page reload

Which forms are enhanced

Any <form> whose action starts with https://api.formclick.io/submit. Other forms on the page are left alone. Each form is enhanced once, even if the script is included twice.

The script reads the key from the hidden access_key field, so keep that field in the form even if you also put the key in the URL.

Form attributes

AttributeDescription
data-success-msgMessage shown after a successful submit. Overrides the default message.
data-recaptcha-v3Your reCAPTCHA v3 site key. The script gets a fresh token right before each submit. See reCAPTCHA.

Events

Both events bubble, so you can listen on the form or on document.

EventWhenevent.detail
fc:successThe submission was saved.The JSON response, e.g. { success, message }
fc:errorValidation, upload or network failure.An Error with a readable message
JavaScript
document.addEventListener('fc:success', (e) => {
  // e.target is the form that was submitted
  gtag('event', 'generate_lead', { form: e.target.id });
});

JavaScript API

MethodDescription
Formclick.enhance(form)Enhance one form element right away.
Formclick.reinit()Scan the page again for Formclick forms.
Formclick.versionThe loaded version, e.g. "2.1.0".
You rarely need these: new forms are picked up automatically. They help when you build a form in memory before attaching it to the page.

CSS classes

ClassElement
.fc-form-msgThe message box added to the form.
.fc-msg-success / .fc-msg-errorSuccess or error variant of the message.
.fc-btn-loadingSubmit button while the form is sending.
.fc-upload-zoneFile drop zone. Gets .fc-drag-over, .fc-has-files and .fc-error-zone.
Still need help? Contact support or email support@formclick.io.