Popup contact form

A button opens a native dialog. The form inside posts to Formgong. Without JavaScript, use the inline snippet instead.

Using Tilda? Paste into a T123 block (paid plan) or use the no-code webhook.

What you are copying

This starter is a button that opens a native dialog. The form inside the dialog posts to Formgong.

The dialog element and a few lines of script are enough. There is no widget library and no font file.

The script calls showModal when the button is clicked, and close when the close button is clicked. It uses addEventListener, not an inline handler.

Without JavaScript the dialog stays closed, because a dialog does not open by itself. That is a limit of this pattern, not a hidden mode.

The extra snippet is the same fields inline, with no dialog and no script. Use it when the page must work with scripts off.

What the dialog does and does not do

The style block sets a system font stack, a border and a max width. It does not import a typeface.

The backdrop is a translucent black. It is only paint. It does not track the visitor.

The form is a normal POST. Closing the dialog does not send anything. Only the submit button posts.

Put one copy of this widget on a page. The ids fg-open, fg-dialog and fg-close must stay unique.

If you need two buttons, point both at the same dialog, or give the second copy new ids and update the script.

access_key, _lang and botcheck sit inside the form, so they are included when it posts.

Delivery

Telegram shows name, email, phone and message in bold. Keep those names even if you translate the labels.

Turnstile is commented out. Enable it in the form settings before you uncomment the widget, and use your own site key.

Free includes 250 submissions a month, immediate Telegram, an email for every submission, and 30 days of retention in the EU.

The preview button on this page opens a dialog that does not post. The copied snippet is what runs on your site.

Formgong operates the backend. Contact support@formgong.com about the service.

Preview

Form code

HTML
<button type="button" id="fg-open">Contact</button>
<dialog id="fg-dialog">
  <form action="https://formgong.com/submit" method="POST" style="position:relative">
  <input type="hidden" name="access_key" value="fk_your_access_key">
  <input type="hidden" name="_lang" value="en">
  <label>Name <input type="text" name="name" autocomplete="name" required></label>
  <label>Email <input type="email" name="email" autocomplete="email" required></label>
  <label>Phone <input type="tel" name="phone" autocomplete="tel"></label>
  <label>Message <textarea name="message" required></textarea></label>
    <div aria-hidden="true" style="position:absolute;inset-inline-start:0;top:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)">
  <label>Leave this field empty <input type="text" name="botcheck" tabindex="-1" autocomplete="off"></label>
</div>
    <!--
Optional. Turn Turnstile on for this form, then remove these comment marks and paste your site key.
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<div class="cf-turnstile" data-sitekey="YOUR_TURNSTILE_SITE_KEY" data-language="en"></div>
-->
    <button type="button" id="fg-close">Close</button>
    <button type="submit">Send</button>
  </form>
</dialog>
<style>
  #fg-dialog { font-family: system-ui, "Segoe UI", sans-serif; border: 1px solid #ccc; border-radius: 12px; padding: 16px; max-width: 28rem; }
  #fg-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
  #fg-dialog label { display: block; margin: 0 0 8px; }
  #fg-dialog input, #fg-dialog textarea { font: inherit; width: 100%; }
</style>
<script>
(function () {
  var dialog = document.getElementById("fg-dialog");
  var open = document.getElementById("fg-open");
  var close = document.getElementById("fg-close");
  if (!dialog || !open || !dialog.showModal) return;
  open.addEventListener("click", function () { dialog.showModal(); });
  if (close) close.addEventListener("click", function () { dialog.close(); });
})();
</script>
The same fields inline, without a dialog
The same fields inline, without a dialog
<form action="https://formgong.com/submit" method="POST" style="position:relative">
  <input type="hidden" name="access_key" value="fk_your_access_key">
  <input type="hidden" name="_lang" value="en">
  <label>Name <input type="text" name="name" autocomplete="name" required></label>
  <label>Email <input type="email" name="email" autocomplete="email" required></label>
  <label>Phone <input type="tel" name="phone" autocomplete="tel"></label>
  <label>Message <textarea name="message" required></textarea></label>
  <div aria-hidden="true" style="position:absolute;inset-inline-start:0;top:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)">
  <label>Leave this field empty <input type="text" name="botcheck" tabindex="-1" autocomplete="off"></label>
</div>
  <!--
Optional. Turn Turnstile on for this form, then remove these comment marks and paste your site key.
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<div class="cf-turnstile" data-sitekey="YOUR_TURNSTILE_SITE_KEY" data-language="en"></div>
-->
  <button type="submit">Send</button>
</form>

Questions and answers

Does the popup work without JavaScript?

No. Use the extra snippet, which is the same form in the page, when you need a no-script path.

Can I open the dialog from a menu link?

Yes, if that control calls showModal on the same dialog. Do not add a second form with the same ids.

Is this a chat widget?

No. It is one form in a dialog. It does not keep a thread, and it does not connect to a chat product.

Where should the access key live?

In the hidden field in the form. It is a public key. Do not invent a server route just to hide it.