Course enrollment form

Enrol a student in a course, online or in a classroom.

Vista previa

Course

Student

Note

Consent

Código del formulario

HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Course enrollment form</title>
<style>
  body { font-family: "Segoe UI", sans-serif; color: #12263a; margin: 0; background: #fff; }
  main { max-width: 640px; margin: 0 auto; padding: 32px 20px 64px; }
  h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
  h2 { font-size: 18px; margin: 18px 0 0; }
  p { line-height: 1.5; }
  form { display: grid; gap: 14px; position: relative; }
  .field { display: grid; gap: 6px; }
  label span, .check span { font-size: 14px; }
  input, select, textarea { font: inherit; color: inherit; padding: 10px 12px; border: 1px solid #b4bdce; border-radius: 8px; width: 100%; box-sizing: border-box; background: #fff; }
  textarea { min-height: 96px; }
  .check { display: flex; gap: 8px; align-items: flex-start; }
  .check input { width: auto; margin-top: 4px; }
  button { background: #3c4ad8; color: #fff; border: 0; border-radius: 8px; padding: 12px 18px; font: inherit; cursor: pointer; }
  .note { background: #fff6eb; padding: 12px 14px; border-radius: 8px; }
  form [data-show-if] { display: none; }
form:has(select[name="track"] option[value="other"]:checked) [data-show-if="track"][data-show-equals="other"] { display: grid; }
</style>
</head>
<body>
<main>
<h1 data-i18n="title">Course enrollment form</h1>
<p data-i18n="lede">Enrol a student in a course, online or in a classroom.</p>


<form id="fg-form" action="https://formgong.com/submit" method="POST" enctype="multipart/form-data" data-sitekey="">
<input type="hidden" name="access_key" value="fk_your_access_key">
<div aria-hidden="true" style="position:absolute;left:-10000px;width:1px;height:1px;overflow:hidden"><label>Leave this field empty<input name="botcheck" tabindex="-1" autocomplete="off"></label></div>
<section><h2 data-i18n="section.course">Course</h2>
<div class="field"><label for="fg-track"><span data-i18n="track">Track</span></label><select id="fg-track" name="track" required><option value="">—</option><option value="language" data-i18n="track.language">Language</option><option value="design" data-i18n="track.design">Design</option><option value="programming" data-i18n="track.programming">Programming</option><option value="other" data-i18n="track.other">Other</option></select></div>
<div class="field" data-show-if="track" data-show-equals="other"><label for="fg-track_other"><span data-i18n="track_other">Which course?</span></label><input id="fg-track_other" name="track_other" type="text" maxlength="120"></div>
<div class="field"><label for="fg-format"><span data-i18n="format">Format</span></label><select id="fg-format" name="format" required><option value="">—</option><option value="online" data-i18n="format.online">Online</option><option value="in_person" data-i18n="format.in_person">In person</option><option value="either" data-i18n="format.either">Either</option></select></div>
<div class="field"><label for="fg-start"><span data-i18n="start">Start</span></label><select id="fg-start" name="start" required><option value="">—</option><option value="asap" data-i18n="start.asap">As soon as possible</option><option value="next_month" data-i18n="start.next_month">Next month</option><option value="flexible" data-i18n="start.flexible">Flexible</option></select></div></section>
<section><h2 data-i18n="section.student">Student</h2>
<div class="field"><label for="fg-name"><span data-i18n="name">Name</span></label><input id="fg-name" name="name" type="text" required maxlength="80" autocomplete="name"></div>
<div class="field"><label for="fg-email"><span data-i18n="email">Email</span></label><input id="fg-email" name="email" type="email" required maxlength="120" autocomplete="email"></div>
<div class="field"><label for="fg-phone"><span data-i18n="phone">Phone</span></label><input id="fg-phone" name="phone" type="tel" maxlength="40" autocomplete="tel"></div>
<div class="field"><label for="fg-level"><span data-i18n="level">Level</span></label><select id="fg-level" name="level" required><option value="">—</option><option value="beginner" data-i18n="level.beginner">Beginner</option><option value="intermediate" data-i18n="level.intermediate">Intermediate</option><option value="advanced" data-i18n="level.advanced">Advanced</option></select></div></section>
<section><h2 data-i18n="section.note">Note</h2>
<div class="field"><label for="fg-note"><span data-i18n="note">Anything the teacher should know?</span></label><textarea id="fg-note" name="note" maxlength="500"></textarea></div></section>
<section><h2 data-i18n="section.consent">Consent</h2>
<div class="field"><label class="check"><input id="fg-consent_contact" name="consent_contact" type="checkbox" value="yes" required><span data-i18n="consent_contact">I agree to be contacted about this request.</span></label></div>
<div class="field"><label class="check"><input id="fg-consent_privacy" name="consent_privacy" type="checkbox" value="yes" required><span data-i18n="consent_privacy">I agree that these answers are stored so the request can be handled.</span></label></div></section>
<!-- Set data-sitekey on this form to YOUR_TURNSTILE_SITE_KEY. Required for attachments. -->
<div data-turnstile></div>
<button type="submit" data-i18n="submit">Send</button>
<p data-status role="status"></p>
</form>
</main>
<script type="application/json" id="fg-labels">{"uk":{"title":"Форма запису на курс","lede":"Запис студента на курс, онлайн або в аудиторії.","submit":"Надіслати","thanks":"Надіслано. Дякуємо.","file_too_big":"До 3 файлів, по 5 MiB, разом до 10 MiB.","section.course":"Курс","track":"Напрям","track.language":"Мова","track.design":"Дизайн","track.programming":"Програмування","track.other":"Інше","track_other":"Який курс?","format":"Формат","format.online":"Онлайн","format.in_person":"Очно","format.either":"Будь-який","start":"Початок","start.asap":"Якнайшвидше","start.next_month":"Наступного місяця","start.flexible":"Гнучко","section.student":"Студент","name":"Ім'я","email":"Електронна пошта","phone":"Телефон","level":"Рівень","level.beginner":"Початківець","level.intermediate":"Середній","level.advanced":"Продвинутий","section.note":"Примітка","note":"Що варто знати викладачу?","section.consent":"Згода","consent_contact":"Погоджуюсь, щоб зі мною зв'язалися щодо цієї заявки.","consent_privacy":"Погоджуюсь, що ці відповіді зберігаються, щоб заявку можна було обробити."},"en":{"title":"Course enrollment form","lede":"Enrol a student in a course, online or in a classroom.","submit":"Send","thanks":"Sent. Thank you.","file_too_big":"Up to 3 files, 5 MiB each and 10 MiB combined.","section.course":"Course","track":"Track","track.language":"Language","track.design":"Design","track.programming":"Programming","track.other":"Other","track_other":"Which course?","format":"Format","format.online":"Online","format.in_person":"In person","format.either":"Either","start":"Start","start.asap":"As soon as possible","start.next_month":"Next month","start.flexible":"Flexible","section.student":"Student","name":"Name","email":"Email","phone":"Phone","level":"Level","level.beginner":"Beginner","level.intermediate":"Intermediate","level.advanced":"Advanced","section.note":"Note","note":"Anything the teacher should know?","section.consent":"Consent","consent_contact":"I agree to be contacted about this request.","consent_privacy":"I agree that these answers are stored so the request can be handled."},"pl":{"title":"Formularz zapisu na kurs","lede":"Zapis na kurs, online albo stacjonarnie.","submit":"Wyślij","thanks":"Wysłano. Dziękujemy.","file_too_big":"Do 3 plików, po 5 MiB, łącznie 10 MiB.","section.course":"Kurs","track":"Kierunek","track.language":"Język","track.design":"Projektowanie","track.programming":"Programowanie","track.other":"Inne","track_other":"Jaki kurs?","format":"Forma","format.online":"Online","format.in_person":"Stacjonarnie","format.either":"Obojętnie","start":"Start","start.asap":"Jak najszybciej","start.next_month":"W przyszłym miesiącu","start.flexible":"Elastycznie","section.student":"Uczestnik","name":"Imię","email":"E-mail","phone":"Telefon","level":"Poziom","level.beginner":"Początkujący","level.intermediate":"Średniozaawansowany","level.advanced":"Zaawansowany","section.note":"Notatka","note":"Co prowadzący powinien wiedzieć?","section.consent":"Zgoda","consent_contact":"Zgadzam się na kontakt w sprawie tego zgłoszenia.","consent_privacy":"Zgadzam się, aby te odpowiedzi zostały zapisane w celu obsługi zgłoszenia."},"tr":{"title":"Kurs kayıt formu","lede":"Çevrimiçi ya da sınıfta bir kursa kayıt.","submit":"Gönder","thanks":"Gönderildi. Teşekkürler.","file_too_big":"En fazla 3 dosya, dosya başına 5 MiB, toplam 10 MiB.","section.course":"Kurs","track":"Alan","track.language":"Dil","track.design":"Tasarım","track.programming":"Programlama","track.other":"Diğer","track_other":"Hangi kurs?","format":"Biçim","format.online":"Çevrimiçi","format.in_person":"Yüz yüze","format.either":"Fark etmez","start":"Başlangıç","start.asap":"En kısa sürede","start.next_month":"Gelecek ay","start.flexible":"Esnek","section.student":"Katılımcı","name":"Ad","email":"E-posta","phone":"Telefon","level":"Seviye","level.beginner":"Başlangıç","level.intermediate":"Orta","level.advanced":"İleri","section.note":"Not","note":"Eğitmenin bilmesi gereken bir şey var mı?","section.consent":"Onay","consent_contact":"Bu talep hakkında benimle iletişime geçilmesini kabul ediyorum.","consent_privacy":"Bu yanıtların talebin işlenmesi için saklanmasını kabul ediyorum."}}</script>
<script>
function mountCaptcha(node, siteKey) {
  if (!node || !siteKey) return () => {};
  let disposed = false;
  let widget;
  function render() {
    if (disposed || !window.turnstile) return;
    window.turnstile.ready(() => {
      if (disposed) return;
      widget = window.turnstile.render(node, { sitekey: siteKey });
      node.dataset.widgetId = widget;
    });
  }
  if (window.turnstile) render();
  else {
    let script = document.querySelector('script[src^="https://challenges.cloudflare.com/turnstile/v0/api.js"]');
    if (!script) {
      script = document.createElement("script");
      script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
      script.async = true;
      document.head.appendChild(script);
    }
    script.addEventListener("load", render, { once: true });
  }
  return () => { disposed = true; if (widget !== undefined) window.turnstile?.remove(widget); };
}
function resetCaptcha(form) {
  const widget = form.querySelector("[data-turnstile]")?.dataset.widgetId;
  if (widget !== undefined) window.turnstile?.reset(widget);
}
(function () {
  var MAX = 5242880;
  var form = document.getElementById("fg-form");
  var packNode = document.getElementById("fg-labels");
  if (!form || !packNode) return;
  var pack = JSON.parse(packNode.textContent);
  function code() {
    var q = new URLSearchParams(location.search).get("lang") || "";
    var raw = (q || document.documentElement.lang || (navigator.language || "en")).slice(0, 2).toLowerCase();
    return pack[raw] ? raw : "en";
  }
  function apply() {
    var dict = pack[code()];
    document.querySelectorAll("[data-i18n]").forEach(function (node) {
      var key = node.getAttribute("data-i18n");
      if (key && typeof dict[key] === "string") node.textContent = dict[key];
    });
  }
  apply();
  var status = form.querySelector("[data-status]");
  form.addEventListener("submit", function (event) {
    event.preventDefault();
    var dict = pack[code()];
    var body = new FormData(form);
    var files = Array.from(body.values()).filter(function (value) { return value instanceof File && value.size; });
    if (files.length > 3 || files.some(function (file) { return file.size > MAX; }) || files.reduce(function (sum,file) { return sum + file.size; },0) > 10 * 1024 * 1024) {
      if (status) status.textContent = dict.file_too_big;
      return;
    }
    var button = form.querySelector("button[type=submit]");
    if (button) button.disabled = true;
    fetch(form.action, { method: "POST", headers: { Accept: "application/json" }, body: body })
      .then(function (response) { return response.json(); }).then(function (result) {
        if (status) status.textContent = result && result.success ? dict.thanks : ((result && result.message) || "error");
      }).catch(function () { if (status) status.textContent = "error"; })
      .finally(function () { if (button) button.disabled = false; resetCaptcha(form); });
  });
  mountCaptcha(form.querySelector("[data-turnstile]"), form.dataset.sitekey);

})();
</script>
</body>
</html>